vim-patch:9.1.1836: 'culopt' "screenline" not redrawn with line("w0") and :retab

Problem:  'cursorlineopt' "screenline" isn't redrawn when moving cursor
          and then using line("w0") and :retab that does nothing.
Solution: Call redraw_for_cursorcolumn() when setting a valid w_virtcol
          (zeertzjq).

closes: vim/vim#18506

a084914361
(cherry picked from commit ba47cb7eda)
This commit is contained in:
zeertzjq
2025-10-08 06:51:15 +08:00
committed by github-actions[bot]
parent e1fe0ed2df
commit d21c23b8c9
6 changed files with 70 additions and 25 deletions

View File

@@ -64,8 +64,7 @@ int coladvance_force(colnr_T wcol)
curwin->w_valid &= ~VALID_VIRTCOL;
} else {
// Virtcol is valid
curwin->w_valid |= VALID_VIRTCOL;
curwin->w_virtcol = wcol;
set_valid_virtcol(curwin, wcol);
}
return rc;
}
@@ -85,8 +84,7 @@ int coladvance(win_T *wp, colnr_T wcol)
wp->w_valid &= ~VALID_VIRTCOL;
} else if (*(ml_get_buf(wp->w_buffer, wp->w_cursor.lnum) + wp->w_cursor.col) != TAB) {
// Virtcol is valid when not on a TAB
wp->w_valid |= VALID_VIRTCOL;
wp->w_virtcol = wcol;
set_valid_virtcol(curwin, wcol);
}
return rc;
}

View File

@@ -181,6 +181,15 @@ static void redraw_for_cursorcolumn(win_T *wp)
}
}
/// Set wp->w_virtcol to a value ("vcol") that is already valid.
/// Handles redrawing if wp->w_virtcol was previously invalid.
void set_valid_virtcol(win_T *wp, colnr_T vcol)
{
wp->w_virtcol = vcol;
redraw_for_cursorcolumn(wp);
wp->w_valid |= VALID_VIRTCOL;
}
/// Calculates how much the 'listchars' "precedes" or 'smoothscroll' "<<<"
/// marker overlaps with buffer text for window "wp".
/// Parameter "extra2" should be the padding on the 2nd line, not the first

View File

@@ -6433,7 +6433,7 @@ void set_fraction(win_T *wp)
/// calculate the new scroll position.
/// TODO(vim): Ensure this also works with wrapped lines.
/// Requires a not fully visible cursor line to be allowed at the bottom of
/// a window("zb"), probably only when 'smoothscroll' is also set.
/// a window ("zb"), probably only when 'smoothscroll' is also set.
void win_fix_scroll(bool resize)
{
if (*p_spk == 'c') {