vim-patch:9.1.0176: Cursor column wrong with 'virtualedit' and conceal

Problem:  Cursor column wrong with 'virtualedit' and conceal.
Solution: Correct cursor column at end of line if never reached.
          (zeertzjq)

closes: vim/vim#14190

253ff4dece
This commit is contained in:
zeertzjq
2024-03-14 06:44:41 +08:00
parent 9599e5d28d
commit 2af1dc0116
3 changed files with 149 additions and 1 deletions

View File

@@ -2451,11 +2451,17 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
// In the cursor line and we may be concealing characters: correct
// the cursor column when we reach its position.
// With 'virtualedit' we may never reach cursor position, but we still
// need to correct the cursor column, so do that at end of line.
if (!did_wcol
&& wp == curwin && lnum == wp->w_cursor.lnum
&& conceal_cursor_line(wp)
&& (int)wp->w_virtcol <= wlv.vcol + wlv.skip_cells) {
&& (wlv.vcol + wlv.skip_cells >= wp->w_virtcol || mb_schar == NUL)) {
wp->w_wcol = wlv.col - wlv.boguscols;
if (wlv.vcol + wlv.skip_cells < wp->w_virtcol) {
// Cursor beyond end of the line with 'virtualedit'.
wp->w_wcol += wp->w_virtcol - wlv.vcol - wlv.skip_cells;
}
wp->w_wrow = wlv.row;
did_wcol = true;
wp->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;