]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1209: colorcolumn not drawn after virtual text lines v9.1.1209
authorMatthias <matthias.rader@outlook.com>
Sun, 16 Mar 2025 18:27:51 +0000 (19:27 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 16 Mar 2025 18:27:51 +0000 (19:27 +0100)
Problem:  colorcolumn not drawn after virtual text lines
Solution: show colorcolumn on correct line with virtual text by adding
          the size of p_extra to virtual column offset (Matthias)

When a line has two or more lines of virtual text above it, the color
column used to appear on the line of the second virtual text line, while
the first virtual text line and the "real" text line did not have a
color column.

The color column for "above" virtual text is positioned by taking the
offset of the size of the virtual text lines and subtracting it from the
"virtual column" that we are in. If the result equals the color column,
this column is colored.

The "virtual column" is calculated from the beginning of the first
virtual text line and continues over the newlines up to the end of the
"real" text. However, the offset from the virtual text was reset at
every line.

Adding all those offsets together leads to the color column being placed
consistently at the line of the "real" text.

related: #12004
related: #16868
closes: #16904

Signed-off-by: Matthias <matthias.rader@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/drawline.c
src/testdir/dumps/Test_prop_multiple_lines_above_1.dump [new file with mode: 0644]
src/testdir/test_textprop.vim
src/version.c

index 1d65f3b4a9d8e5912f300d5eddf03cdfbeb3c492..764d0fbaa50e7050051420729c3edeb91c04dea0 100644 (file)
@@ -2274,7 +2274,7 @@ win_line(
                                }
 
                                if (above)
-                                   wlv.vcol_off_tp = vim_strsize(wlv.p_extra);
+                                   wlv.vcol_off_tp += vim_strsize(wlv.p_extra);
 
                                if (lcs_eol_one < 0
                                        && wp->w_p_wrap
diff --git a/src/testdir/dumps/Test_prop_multiple_lines_above_1.dump b/src/testdir/dumps/Test_prop_multiple_lines_above_1.dump
new file mode 100644 (file)
index 0000000..be41f74
--- /dev/null
@@ -0,0 +1,16 @@
+| +0#af5f00255#ffffff0@3|a+0#0000001#ffff4012|b|o|v|e|1| +0#0000000#ffffff0@49
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|2| +0#0000000#ffffff0@49
+| +0#af5f00255&@1|1| |1+0#0000000&@7| | +0&#ffd7d7255| +0&#ffffff0@45
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|1| +0#0000000#ffffff0@49
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|2| +0#0000000#ffffff0@49
+| +0#af5f00255&@1|2| | +0#0000000&@8| +0&#ffd7d7255| +0&#ffffff0@45
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|1| +0#0000000#ffffff0@49
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|2| +0#0000000#ffffff0@49
+| +0#af5f00255&@1|3| |3+0#0000000&@8| +0&#ffd7d7255| +0&#ffffff0@45
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|1| +0#0000000#ffffff0@49
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|2| +0#0000000#ffffff0@49
+| +0#af5f00255&@1|4| | +0#0000000&@8| +0&#ffd7d7255| +0&#ffffff0@45
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|1| +0#0000000#ffffff0@49
+| +0#af5f00255&@3|a+0#0000001#ffff4012|b|o|v|e|2| +0#0000000#ffffff0@49
+| +0#af5f00255&@1|5| >5+0#0000000&@8|5+0&#ffd7d7255|5+0&#ffffff0| @44
+@42|5|,|1|-|1@1|3| @6|A|l@1| 
index fe2d2df770c7171447d148b06775725bb1bf6c8e..abc63652ec1778af24dd1df5b23fb46c4d5c3b6a 100644 (file)
@@ -3203,6 +3203,28 @@ func Test_prop_with_text_above_below_empty()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_prop_multiple_lines_above()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      setlocal number colorcolumn=10
+      call setline(1, ['11111111', '', '333333333', '', '55555555555'])
+
+      let vt = 'test'
+      call prop_type_add(vt, {'highlight': 'ToDo'})
+      for ln in range(1, line('$'))
+        call prop_add(ln, 0, {'type': vt, 'text': 'above1', 'text_align': 'above'})
+        call prop_add(ln, 0, {'type': vt, 'text': 'above2', 'text_align': 'above'})
+      endfor
+      normal G
+  END
+  call writefile(lines, 'XscriptPropMultipleLinesAbove', 'D')
+  let buf = RunVimInTerminal('-S XscriptPropMultipleLinesAbove', #{rows: 16, cols: 60})
+  call VerifyScreenDump(buf, 'Test_prop_multiple_lines_above_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_prop_with_multibyte_above()
   CheckRunVimInTerminal
 
index fc9536f2688f720b839c6850b34db3b0942b0aa7..7e317b32892648683ec7c8264e151c80961f46b0 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1209,
 /**/
     1208,
 /**/