]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4929: off-by-one error in in statusline item v8.2.4929
authorLemonBoy <thatlemon@gmail.com>
Mon, 9 May 2022 20:03:47 +0000 (21:03 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 9 May 2022 20:03:47 +0000 (21:03 +0100)
Problem:    Off-by-one error in in statusline item.
Solution:   Subtrace one less. (closes #10394, closes #5599)

src/buffer.c
src/testdir/dumps/Test_statusline_hl.dump [new file with mode: 0644]
src/testdir/test_statusline.vim
src/version.c

index 17b1493800b85907b710ed97d15833be79a0c43f..35711f5feb320bc5f58cb34dbf6ae373765a200d 100644 (file)
@@ -4446,7 +4446,8 @@ build_stl_str_hl(
                // correct the start of the items for the truncation
                for (l = stl_groupitem[groupdepth] + 1; l < curitem; l++)
                {
-                   stl_items[l].stl_start -= n;
+                   // Minus one for the leading '<' added above.
+                   stl_items[l].stl_start -= n - 1;
                    if (stl_items[l].stl_start < t)
                        stl_items[l].stl_start = t;
                }
diff --git a/src/testdir/dumps/Test_statusline_hl.dump b/src/testdir/dumps/Test_statusline_hl.dump
new file mode 100644 (file)
index 0000000..cebece5
--- /dev/null
@@ -0,0 +1,6 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|<+0#ffffff16#e000002|F|G+0#0000e05#ffffff0|H|I| @69
+| +0#0000000&@74
index eaf152593d425d5ea9b84b9fe89c6d05cbab76e0..7c75f61a871431d5f2fbdac747e6988629f69c28 100644 (file)
@@ -469,7 +469,6 @@ func Test_statusline_removed_group()
   call writefile(lines, 'XTest_statusline')
 
   let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 10, 'cols': 50})
-  call TermWait(buf, 50)
   call VerifyScreenDump(buf, 'Test_statusline_1', {})
 
   " clean up
@@ -541,4 +540,22 @@ func Test_statusline_verylong_filename()
   bwipe!
 endfunc
 
+func Test_statusline_highlight_truncate()
+  CheckScreendump
+
+  let lines =<< trim END
+    set laststatus=2
+    hi! link User1 Directory
+    hi! link User2 ErrorMsg
+    set statusline=%.5(%1*ABC%2*DEF%1*GHI%)
+  END
+  call writefile(lines, 'XTest_statusline')
+
+  let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6})
+  call VerifyScreenDump(buf, 'Test_statusline_hl', {})
+
+  call StopVimInTerminal(buf)
+  call delete('XTest_statusline')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index c069781c344564c8617080061c4de1a97005725a..6fbc3bec02d8d13e88d055eb5442660b6b30bcaa 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4929,
 /**/
     4928,
 /**/