]> granicus.if.org Git - vim/commitdiff
patch 8.2.4091: virtcol is recomputed for statusline unnecessarily v8.2.4091
authorzeertzjq <zeertzjq@outlook.com>
Fri, 14 Jan 2022 20:11:38 +0000 (20:11 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 14 Jan 2022 20:11:38 +0000 (20:11 +0000)
Problem:    Virtcol is recomputed for statusline unnecessarily.
Solution:   Just use "w_virtcol". (closes #9523)

src/buffer.c
src/testdir/test_statusline.vim
src/version.c

index 3445b204f3d5571cdadeb14680dd01581e97bb2a..08db0fc28e5f435fbb040894613197f449607c67 100644 (file)
@@ -4610,15 +4610,7 @@ build_stl_str_hl(
 
        case STL_VIRTCOL:
        case STL_VIRTCOL_ALT:
-           // In list mode virtcol needs to be recomputed
-           virtcol = wp->w_virtcol;
-           if (wp->w_p_list && wp->w_lcs_chars.tab1 == NUL)
-           {
-               wp->w_p_list = FALSE;
-               getvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL);
-               wp->w_p_list = TRUE;
-           }
-           ++virtcol;
+           virtcol = wp->w_virtcol + 1;
            // Don't display %V if it's the same as %c.
            if (opt == STL_VIRTCOL_ALT
                    && (virtcol == (colnr_T)(!(State & INSERT) && empty_line
index a952de69b9046af0bf2a2b824a7a8f3381ab2ae5..28d8798fe8690a700342275d46271d876da67fca 100644 (file)
@@ -196,7 +196,16 @@ func Test_statusline()
   set virtualedit=all
   norm 10|
   call assert_match('^10,-10\s*$', s:get_statusline())
+  set list
+  call assert_match('^10,-10\s*$', s:get_statusline())
   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 ",PRV".
index b65dac3c59393a396dae3cfd4a7fe5a62fd4eb3f..525c86a764517d386edcb673942c3e9a77ff5fc9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4091,
 /**/
     4090,
 /**/