Skip to content

Commit 346f18e

Browse files
committed
patch 8.2.0378: prop_find() does not find all props
Problem: prop_find() does not find all props. Solution: Check being in the start line. (Axel Forsman, closes #5776)
1 parent d47e6f0 commit 346f18e

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/testdir/test_textprop.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,17 @@ func Test_prop_find()
213213
call prop_type_delete('prop_name')
214214
endfunc
215215

216+
func Test_prop_find_smaller_len_than_match_col()
217+
new
218+
call prop_type_add('test', {'highlight': 'ErrorMsg'})
219+
call setline(1, ['xxxx', 'x'])
220+
call prop_add(1, 4, {'type': 'test'})
221+
call assert_equal({'id': 0, 'lnum': 1, 'col': 4, 'type': 'test', 'length': 0, 'start': 1, 'end': 1},
222+
\ prop_find({'type': 'test', 'lnum': 2, 'col': 1}, 'b'))
223+
bwipe!
224+
call prop_type_delete('test')
225+
endfunc
226+
216227
func Test_prop_add()
217228
new
218229
call AddPropTypes()

src/textprop.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,14 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
663663
mch_memmove(&prop, text + textlen + i * sizeof(textprop_T),
664664
sizeof(textprop_T));
665665

666-
if (dir < 0)
667-
{
668-
if (col < prop.tp_col)
669-
break;
670-
}
671-
else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col)
672-
continue;
666+
if (lnum == lnum_start)
667+
if (dir < 0)
668+
{
669+
if (col < prop.tp_col)
670+
break;
671+
}
672+
else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col)
673+
continue;
673674

674675
if (prop.tp_id == id || prop.tp_type == type_id)
675676
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
378,
741743
/**/
742744
377,
743745
/**/

0 commit comments

Comments
 (0)