When mode-keys is set to vi, do not allow the cursor to go into the

invisible extra cell to the right of the visible text. This is closer to
what vi(1) does. From Max Vim in GitHub issue 5070.
This commit is contained in:
nicm
2026-05-17 13:12:21 +00:00
parent bbea6e6375
commit f12d7b4e67
3 changed files with 61 additions and 11 deletions

View File

@@ -45,15 +45,20 @@ grid_reader_line_length(struct grid_reader *gr)
/* Move cursor forward one position. */
void
grid_reader_cursor_right(struct grid_reader *gr, int wrap, int all)
grid_reader_cursor_right(struct grid_reader *gr, int wrap, int all, int onemore)
{
u_int px;
struct grid_cell gc;
if (all)
px = gr->gd->sx;
else
else if (onemore)
px = grid_reader_line_length(gr);
else {
px = grid_reader_line_length(gr);
if (px != 0)
px--;
}
if (wrap && gr->cx >= px && gr->cy < gr->gd->hsize + gr->gd->sy - 1) {
grid_reader_cursor_start_of_line(gr, 0);