]> granicus.if.org Git - vim/commitdiff
patch 8.1.1571: textprop highlight starts too early if just after a tab v8.1.1571
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Jun 2019 15:34:24 +0000 (17:34 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Jun 2019 15:34:24 +0000 (17:34 +0200)
Problem:    textprop highlight starts too early if just after a tab.
Solution:   Check if still drawing a previous character. (closes #4558)

src/screen.c
src/testdir/dumps/Test_textprop_tab.dump [new file with mode: 0644]
src/testdir/test_textprop.vim
src/version.c

index 05639c30b70e1a550b2db1d9570dadba6a47b038..d2227a888418d0c6ff0e934bca12ac122ac60f45 100644 (file)
@@ -4391,6 +4391,9 @@ win_line(
                int pi;
                int bcol = (int)(ptr - line);
 
+               if (n_extra > 0)
+                   --bcol;  // still working on the previous char, e.g. Tab
+
                // Check if any active property ends.
                for (pi = 0; pi < text_props_active; ++pi)
                {
diff --git a/src/testdir/dumps/Test_textprop_tab.dump b/src/testdir/dumps/Test_textprop_tab.dump
new file mode 100644 (file)
index 0000000..a1b7705
--- /dev/null
@@ -0,0 +1,6 @@
+| +0&#ffffff0@6> |x+0&#ffff4012@2| +0&#ffffff0@63
+|x| @6|x+0&#ffff4012@2| +0&#ffffff0@63
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1|-|8| @8|A|l@1| 
index 08c079cfa4eac90b7c677ed52bc55d63c80ad925..36eeb709b8af3f580659a0a61c08b824786980d1 100644 (file)
@@ -759,6 +759,26 @@ func Test_textprop_screenshot_visual()
   call RunTestVisualBlock(4, '02')
 endfunc
 
+func Test_textprop_after_tab()
+  let lines =<< trim END
+       call setline(1, [
+             \ "\txxx",
+             \ "x\txxx",
+             \ ])
+       hi SearchProp ctermbg=yellow
+       call prop_type_add('search', {'highlight': 'SearchProp'})
+       call prop_add(1, 2, {'length': 3, 'type': 'search'})
+       call prop_add(2, 3, {'length': 3, 'type': 'search'})
+  END
+  call writefile(lines, 'XtestPropTab')
+  let buf = RunVimInTerminal('-S XtestPropTab', {'rows': 6})
+  call VerifyScreenDump(buf, 'Test_textprop_tab', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('XtestPropTab')
+endfunc
+
 " Adding a text property to a new buffer should not fail
 func Test_textprop_empty_buffer()
   call prop_type_add('comment', {'highlight': 'Search'})
index d71b86e13faaa6bc8a7a3f627459e30a4823f113..19b6aa76d5acc0e578fd0987f6c6bce377c6dec4 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1571,
 /**/
     1570,
 /**/