vim-patch:8.2.2904: "g$" causes scroll if half a double width char is visible

Problem:    "g$" causes scroll if half a double width char is visible.
Solution:   Advance to the last fully visible character. (closes vim/vim#8254)
74ede80aeb
This commit is contained in:
zeertzjq
2022-07-05 16:25:34 +08:00
parent d0835617fa
commit f42657cbcf
2 changed files with 35 additions and 3 deletions

View File

@@ -6157,6 +6157,16 @@ static void nv_g_cmd(cmdarg_T *cap)
i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1;
coladvance((colnr_T)i);
// if the character doesn't fit move one back
if (curwin->w_cursor.col > 0 && utf_ptr2cells((const char *)get_cursor_pos_ptr()) > 1) {
colnr_T vcol;
getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol);
if (vcol >= curwin->w_leftcol + curwin->w_width - col_off) {
curwin->w_cursor.col--;
}
}
// Make sure we stick in this column.
validate_virtcol();
curwin->w_curswant = curwin->w_virtcol;