summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--screen-write.c8
-rw-r--r--tty.c5
2 files changed, 8 insertions, 5 deletions
diff --git a/screen-write.c b/screen-write.c
index 50abb174..90511e30 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -1071,8 +1071,11 @@ screen_write_cell(struct screen_write_ctx *ctx,
return;
}
+ /* Initialise the redraw context, saving the last cell. */
+ screen_write_initctx(ctx, &ttyctx, 1);
+
/* If in insert mode, make space for the cells. */
- if (s->mode & MODE_INSERT && s->cx <= screen_size_x(s) - width) {
+ if ((s->mode & MODE_INSERT) && s->cx <= screen_size_x(s) - width) {
xx = screen_size_x(s) - s->cx - width;
grid_move_cells(s->grid, s->cx + width, s->cx, s->cy, xx);
insert = 1;
@@ -1084,9 +1087,6 @@ screen_write_cell(struct screen_write_ctx *ctx,
s->cx = 0; /* carriage return */
}
- /* Initialise the redraw context, saving the last cell. */
- screen_write_initctx(ctx, &ttyctx, 1);
-
/* Sanity checks. */
if (((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - width)
|| s->cy > screen_size_y(s) - 1)
diff --git a/tty.c b/tty.c
index bf5eac09..c7e603c1 100644
--- a/tty.c
+++ b/tty.c
@@ -1000,7 +1000,10 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
* The pane doesn't fill the entire line, the linefeed
* will already have happened, so just move the cursor.
*/
- tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1);
+ if (ctx->ocy != wp->yoff + wp->sy)
+ tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1);
+ else
+ tty_cursor_pane(tty, ctx, 0, ctx->ocy);
} else if (tty->cx < tty->sx) {
/*
* The cursor isn't in the last position already, so