Merge pull request #17094 from zeertzjq/vim-8.2.4091

vim-patch:8.2.4091: virtcol is recomputed for statusline unnecessarily
This commit is contained in:
bfredl 2022-01-27 08:35:52 +01:00 committed by GitHub
commit 0813b9fde4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -4001,14 +4001,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
case STL_VIRTCOL: case STL_VIRTCOL:
case STL_VIRTCOL_ALT: { case STL_VIRTCOL_ALT: {
// In list mode virtcol needs to be recomputed colnr_T virtcol = wp->w_virtcol + 1;
colnr_T virtcol = wp->w_virtcol;
if (wp->w_p_list && wp->w_p_lcs_chars.tab1 == NUL) {
wp->w_p_list = false;
getvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL);
wp->w_p_list = true;
}
virtcol++;
// Don't display %V if it's the same as %c. // Don't display %V if it's the same as %c.
if (opt == STL_VIRTCOL_ALT if (opt == STL_VIRTCOL_ALT
&& (virtcol == (colnr_T)(!(State & INSERT) && empty_line && (virtcol == (colnr_T)(!(State & INSERT) && empty_line

View File

@ -186,7 +186,16 @@ func Test_statusline()
set virtualedit=all set virtualedit=all
norm 10| norm 10|
call assert_match('^10,-10\s*$', s:get_statusline()) call assert_match('^10,-10\s*$', s:get_statusline())
set list
call assert_match('^10,-10\s*$', s:get_statusline())
set virtualedit& set virtualedit&
exe "norm A\<Tab>\<Tab>a\<Esc>"
" In list mode a <Tab> is shown as "^I", which is 2-wide.
call assert_match('^9,-9\s*$', s:get_statusline())
set list&
" Now the second <Tab> ends at the 16th screen column.
call assert_match('^17,-17\s*$', s:get_statusline())
undo
" %w: Preview window flag, text is "[Preview]". " %w: Preview window flag, text is "[Preview]".
" %W: Preview window flag, text is ",PRV". " %W: Preview window flag, text is ",PRV".