]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1922: Wrong virtcol('$') with virtual text at EOL v9.1.1922
authorzeertzjq <zeertzjq@outlook.com>
Thu, 20 Nov 2025 20:35:12 +0000 (20:35 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 20 Nov 2025 20:35:12 +0000 (20:35 +0000)
Problem:  Wrong virtcol('$') with virtual text at EOL (rickhowe).
Solution: Also add 1 to end virtcol when there is virtual text.
          (zeertzjq)

fixes: #18761
closes: #18762

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/charset.c
src/testdir/test_textprop.vim
src/version.c

index 29936e7d9fec502f7dc599e825f465b02ddee0b9..829ad37201811d7689b6231e96bbe89634559f1c 100644 (file)
@@ -1702,8 +1702,7 @@ getvcol(
            {
                incr = 1;       // NUL at end of line only takes one column
 #ifdef FEAT_PROP_POPUP
-               if (cts.cts_cur_text_width > 0)
-                   incr = cts.cts_cur_text_width;
+               incr += cts.cts_cur_text_width;
                on_NUL = TRUE;
 #endif
                break;
index d3357524196fcf60fa64216b9361ac24bcf344f3..975a5846ac4e24d306bbd80ba9bd80159aac0648 100644 (file)
@@ -4403,6 +4403,22 @@ func Test_text_eol_long_wrap_smoothscroll()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_text_eol_virtcol()
+  new
+  call prop_type_add('test', #{highlight: 'ErrorMsg'})
+  call setline(1, repeat(['1234567890'], 6))
+
+  for [ln, tx] in [[2, 'a'], [3, 'ab'], [4, 'abc'], [5, 'abcd'], [6, 'αβγ口']]
+    let co = col([ln, '$'])
+    call assert_equal(11, virtcol([ln, '$']))
+    call prop_add(ln, co, #{type: 'test', text: tx})
+    call assert_equal(11 + strwidth(tx), virtcol([ln, '$']))
+  endfor
+
+  bwipe!
+  call prop_type_delete('test')
+endfunc
+
 func Test_text_below_nowrap()
   CheckScreendump
   CheckRunVimInTerminal
index 568aaab9aa6e9294672a796e4c0a5331d189231a..fe2371cb1d857c93cc6a9b6ba1d1a8742a5578d8 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1922,
 /**/
     1921,
 /**/