]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0124: display of below/right virtual text with non-virtual text overlap v9.1.0124
authorDylan Thacker-Smith <dylan.ah.smith@gmail.com>
Wed, 21 Feb 2024 20:00:59 +0000 (21:00 +0100)
committerChristian Brabandt <cb@256bit.org>
Wed, 21 Feb 2024 20:00:59 +0000 (21:00 +0100)
Problem:  Virtual text with text_align 'right'/'below' wasn't being
          used when a non-virtual text property overlaps with the end of
          the line. This was because the non-virtual text property had a
          higher priority, preventing the virtual text from being used.
Solution: Fix the sorting of text properties so virtual text properties
          have a higher priority than non-virtual text properties.
          (Dylan Thacker-Smith)

related: #14063

Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/dumps/Test_virtual_text_overlap_with_highlight_1.dump [new file with mode: 0644]
src/testdir/test_textprop.vim
src/textprop.c
src/version.c

diff --git a/src/testdir/dumps/Test_virtual_text_overlap_with_highlight_1.dump b/src/testdir/dumps/Test_virtual_text_overlap_with_highlight_1.dump
new file mode 100644 (file)
index 0000000..d81456f
--- /dev/null
@@ -0,0 +1,8 @@
+| +0#af5f00255#ffffff0@1|1| |o+0#0000000&|n|e| @52
+| +0#af5f00255&@1|2| |t+0#0000000&|w|o| @52
+| +0#af5f00255&@3|s+0#ffffff16#ff404010|y|n|t|a|x| |e|r@1|o|r| +0#0000000#ffffff0@43
+| +0#af5f00255&@1|3| >t+0#0000000&|h|r|e@1| @50
+| +0#af5f00255&@1|4| |f+0#0000000&|o|u|r+0#e000002&| +0#0000000&@40|o+0#ffffff16#ff404010|t|h|e|r| |e|r@1|o|r
+| +0#af5f00255#ffffff0@1|5| |f+0#e000002&|i+0#0000000&|v|e| @51
+|~+0#4040ff13&| @58
+| +0#0000000&@41|3|,|1| @10|A|l@1| 
index 97fea60e6d669df67bfbab51093dafd641604019..18ff3df2ee8d762e203908c53b509f1f47015412 100644 (file)
@@ -4090,6 +4090,46 @@ func Test_text_below_nowrap()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_virtual_text_overlap_with_highlight()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      vim9script
+      setline(1, ['one', 'two', 'three', 'four', 'five'])
+      set number
+
+      prop_type_add('demo_highlight_warning', {highlight: 'WarningMsg'})
+      prop_type_add('demo_virtual_text_error', {highlight: 'Error'})
+
+      prop_add(2, 4, {
+        type: 'demo_highlight_warning',
+        end_col: 4,
+      })
+      prop_add(2, 0, {
+        type: 'demo_virtual_text_error',
+        text: 'syntax error',
+        text_align: 'below',
+      })
+      normal 2j
+
+      prop_add(4, 4, {
+        type: 'demo_highlight_warning',
+        end_lnum: 5,
+        end_col: 1,
+      })
+      prop_add(4, 0, {
+        type: 'demo_virtual_text_error',
+        text: 'other error',
+        text_align: 'right',
+      })
+  END
+  call writefile(lines, 'XVirtualTextOverlapWithHighlight', 'D')
+  let buf = RunVimInTerminal('-S XVirtualTextOverlapWithHighlight', #{rows: 8, cols: 60})
+  call VerifyScreenDump(buf, 'Test_virtual_text_overlap_with_highlight_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_virtual_text_in_popup_highlight()
   CheckRunVimInTerminal
 
index 168b1808fb9e33597d46e3952bcf2491db5880e2..cd07844f142f5b93b55912e703577ec74e89c8bb 100644 (file)
@@ -758,6 +758,11 @@ text_prop_compare(const void *s1, const void *s2)
     tp2 = &text_prop_compare_props[idx2];
     col1 = tp1->tp_col;
     col2 = tp2->tp_col;
+
+    // property that inserts text has priority over one that doesn't
+    if ((tp1->tp_id < 0) != (tp2->tp_id < 0))
+       return tp1->tp_id < 0 ? 1 : -1;
+
     if (col1 == MAXCOL || col2 == MAXCOL)
     {
        int order1 = text_prop_order(tp1->tp_flags);
@@ -768,10 +773,6 @@ text_prop_compare(const void *s1, const void *s2)
            return order1 < order2 ? 1 : -1;
     }
 
-    // property that inserts text has priority over one that doesn't
-    if ((tp1->tp_id < 0) != (tp2->tp_id < 0))
-       return tp1->tp_id < 0 ? 1 : -1;
-
     // check highest priority, defined by the type
     pt1 = text_prop_type_by_id(text_prop_compare_buf, tp1->tp_type);
     pt2 = text_prop_type_by_id(text_prop_compare_buf, tp2->tp_type);
index 650fb4fb4b8540bb5f5f58492ed811775bd6ac23..1893b5f2b7ae617b565f54a3a13aa2b363621d0e 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    124,
 /**/
     123,
 /**/