diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-02 19:59:00 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-02 19:59:00 +0200 |
commit | 4da7a259f6b28a4f855a6fa7d0ede5e038600154 (patch) | |
tree | f5a7b2fa464a077b0cff49553aa3b255557dda1e | |
parent | 6efa46f4efd226f65634ba8eb6ddee54de1de563 (diff) | |
download | vim-git-4da7a259f6b28a4f855a6fa7d0ede5e038600154.tar.gz |
patch 8.2.1568: prop_find() skips properties in the same linev8.2.1568
Problem: prop_find() skips properties in the same line if "skipstart" is
used.
Solution: Use "continue" instead of "break". (closes #6840)
-rw-r--r-- | src/testdir/test_textprop.vim | 16 | ||||
-rw-r--r-- | src/textprop.c | 4 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 9db5275d5..5990fbf3f 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -211,6 +211,22 @@ func Test_prop_find() call prop_clear(1,6) call prop_type_delete('prop_name') + + " Multiple props per line, start on the first, should find the second. + let expected = {'lnum': 1, 'id': 0, 'col': 14, 'end': 1, 'type': 'misspell', 'length': 2, 'start': 1} + eval ['the quikc bronw fox jumsp over the layz dog']->repeat(2)->setline(1) + call prop_type_add('misspell', #{highlight: 'ErrorMsg'}) + for lnum in [1, 2] + for col in [8, 14, 24, 38] + call prop_add(lnum, col, #{type: 'misspell', length: 2}) + endfor + endfor + call cursor(1, 8) + let result = prop_find(#{type: 'misspell', skipstart: 1}, 'f') + call assert_equal(expected, result) + + call prop_type_delete('misspell') + bwipe! endfunc func Test_prop_find_smaller_len_than_match_col() diff --git a/src/textprop.c b/src/textprop.c index 0645e1fd7..9dff6b869 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -718,7 +718,7 @@ f_prop_find(typval_T *argvars, typval_T *rettv) // on a prop and we're not skipping. if (start_pos_has_prop && !skipstart) dir = -1; - break; + continue; } // If skipstart is true, skip the prop at start pos (even if @@ -726,7 +726,7 @@ f_prop_find(typval_T *argvars, typval_T *rettv) if (start_pos_has_prop && skipstart && !seen_end) { start_pos_has_prop = 0; - break; + continue; } prop_fill_dict(rettv->vval.v_dict, &prop, buf); diff --git a/src/version.c b/src/version.c index e1d3b12ca..840c32535 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1568, +/**/ 1567, /**/ 1566, |