Commit: patch 9.2.0375: prop_find() does not find a virt text in starting line

0 views
Skip to first unread message

Christian Brabandt

unread,
12:30 PM (6 hours ago) 12:30 PM
to vim...@googlegroups.com
patch 9.2.0375: prop_find() does not find a virt text in starting line

Commit: https://github.com/vim/vim/commit/c9d4c1dc43c457173bf342f16f21c4cf9a0d9d2d
Author: Furkan Sahin <furka...@proton.me>
Date: Mon Apr 20 16:12:54 2026 +0000

patch 9.2.0375: prop_find() does not find a virt text in starting line

Problem: prop_find() does not find a virt text in the starting line
(@rickhowe, after v9.2.0320)
Solution: Do not skip virtual text properties with tp_col == MAXCOL on
the starting line (Furkan Sahin)

The column matching logic incorrectly skipped virtual text properties
with tp_col == MAXCOL on the starting line. Exclude such properties
from the column range check so they are always found.

fixes: #20013
closes: #20019

Signed-off-by: Furkan Sahin <furka...@proton.me>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index f94acfc97..a57493bc8 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -4907,4 +4907,38 @@ func Test_textprop_materialize_list()
call assert_equal([], prop_list(1, #{ids: 3->range()}))
endfunc

+func Test_prop_find_floating_vtext()
+ new
+ call setline(1, ['111', '222', '333'])
+ let tn = 'test'
+ call prop_type_add(tn, {'highlight': 'Search'})
+ for ln in range(1, 3)
+ call prop_add(ln, 0, {'type': tn, 'text': '-----', 'text_align': 'above'})
+ endfor
+ " forward search must find the virtual text on the starting line
+ let found = prop_find({'type': tn, 'lnum': 1, 'col': 1})
+ call assert_equal(1, found.lnum)
+ call assert_equal('-----', found.text)
+ " backward search must also find the virtual text on the starting line
+ let found = prop_find({'type': tn, 'lnum': 1, 'col': 1}, 'b')
+ call assert_equal(1, found.lnum)
+ call assert_equal('-----', found.text)
+ bwipe!
+ call prop_type_delete(tn)
+ " Also cover 'below' and 'right' aligned virtual text (also tp_col==MAXCOL)
+ for align in ['below', 'right']
+ new
+ call setline(1, ['aaa', 'bbb'])
+ call prop_type_add(tn, {'highlight': 'Search'})
+ call prop_add(1, 0, {'type': tn, 'text': 'VT', 'text_align': align})
+ let found = prop_find({'type': tn, 'lnum': 1, 'col': 1})
+ call assert_equal(1, found.lnum, 'forward, align=' .. align)
+ call assert_equal('VT', found.text, 'forward, align=' .. align)
+ let found = prop_find({'type': tn, 'lnum': 1, 'col': 1}, 'b')
+ call assert_equal(1, found.lnum, 'backward, align=' .. align)
+ call assert_equal('VT', found.text, 'backward, align=' .. align)
+ bwipe!
+ call prop_type_delete(tn)
+ endfor
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/textprop.c b/src/textprop.c
index b4aedf98d..48cbad4b6 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1967,12 +1967,16 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
// after `col`, depending on the search direction.
if (lnum == lnum_start)
{
+ bool is_floating_vtext = prop.tp_id < 0
+ && prop.tp_col == MAXCOL;
if (dir == BACKWARD)
{
- if (prop.tp_col > col)
+ // Virtual text with MAXCOL always matches any column
+ if (!is_floating_vtext && prop.tp_col > col)
continue;
}
- else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col)
+ else if (!is_floating_vtext
+ && prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col)
continue;
}
if (both ? prop.tp_id == id && prop.tp_type == type_id
diff --git a/src/version.c b/src/version.c
index f36742a33..47ea1bac7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 375,
/**/
374,
/**/
Reply all
Reply to author
Forward
0 new messages