Patch 8.2.0372

10 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 11, 2020, 2:17:36 PM3/11/20
to vim...@googlegroups.com

Patch 8.2.0372
Problem: Prop_find() may not find text property at start of the line.
Solution: Adjust the loop to find properties. (Axel Forsman, closes #5761,
closes #5663)
Files: src/testprop.c, src/testdir/test_textprop.vim


*** ../vim-8.2.0371/src/textprop.c 2020-03-05 21:52:51.058454475 +0100
--- src/textprop.c 2020-03-11 19:13:54.629916407 +0100
***************
*** 663,686 ****
mch_memmove(&prop, text + textlen + i * sizeof(textprop_T),
sizeof(textprop_T));

if (prop.tp_id == id || prop.tp_type == type_id)
{
// Check if the starting position has text props.
! if (lnum_start == lnum)
! {
! if (col >= prop.tp_col
! && (col <= prop.tp_col + prop.tp_len-1))
! start_pos_has_prop = 1;
! }
! else
! {
! // Not at the first line of the search so adjust col to
! // indicate that we're continuing from prev/next line.
! if (dir < 0)
! col = buf->b_ml.ml_line_len;
! else
! col = 1;
! }

prop_start = !(prop.tp_flags & TP_FLAG_CONT_PREV);
prop_end = !(prop.tp_flags & TP_FLAG_CONT_NEXT);
--- 663,684 ----
mch_memmove(&prop, text + textlen + i * sizeof(textprop_T),
sizeof(textprop_T));

+ if (dir < 0)
+ {
+ if (col < prop.tp_col)
+ break;
+ }
+ else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col)
+ continue;
+
if (prop.tp_id == id || prop.tp_type == type_id)
{
// Check if the starting position has text props.
! if (lnum_start == lnum
! && col >= prop.tp_col
! && (col <= prop.tp_col + prop.tp_len
! - (prop.tp_len != 0)))
! start_pos_has_prop = 1;

prop_start = !(prop.tp_flags & TP_FLAG_CONT_PREV);
prop_end = !(prop.tp_flags & TP_FLAG_CONT_NEXT);
***************
*** 705,721 ****
break;
}

- if (dir < 0)
- {
- if (col < prop.tp_col)
- break;
- }
- else
- {
- if (col > prop.tp_col + prop.tp_len-1)
- break;
- }
-
prop_fill_dict(rettv->vval.v_dict, &prop, buf);
dict_add_number(rettv->vval.v_dict, "lnum", lnum);

--- 703,708 ----
***************
*** 735,740 ****
--- 722,729 ----
break;
lnum--;
}
+ // Adjust col to indicate that we're continuing from prev/next line.
+ col = dir < 0 ? buf->b_ml.ml_line_len : 1;
}
}

*** ../vim-8.2.0371/src/testdir/test_textprop.vim 2020-03-05 21:52:51.058454475 +0100
--- src/testdir/test_textprop.vim 2020-03-11 19:07:38.924029897 +0100
***************
*** 1166,1168 ****
--- 1166,1195 ----
call prop_remove({'type': 'test'})
call prop_type_delete('test')
endfunc
+
+ func Test_find_prop_later_in_line()
+ new
+ call prop_type_add('test', {'highlight': 'ErrorMsg'})
+ call setline(1, 'just some text')
+ call prop_add(1, 1, {'length': 4, 'type': 'test'})
+ call prop_add(1, 10, {'length': 3, 'type': 'test'})
+
+ call assert_equal({'id': 0, 'lnum': 1, 'col': 10, 'end': 1, 'type': 'test', 'length': 3, 'start': 1},
+ \ prop_find(#{type: 'test', lnum: 1, col: 6}))
+
+ bwipe!
+ call prop_type_delete('test')
+ endfunc
+
+ func Test_find_zerowidth_prop_sol()
+ new
+ call prop_type_add('test', {'highlight': 'ErrorMsg'})
+ call setline(1, 'just some text')
+ call prop_add(1, 1, {'length': 0, 'type': 'test'})
+
+ call assert_equal({'id': 0, 'lnum': 1, 'col': 1, 'end': 1, 'type': 'test', 'length': 0, 'start': 1},
+ \ prop_find(#{type: 'test', lnum: 1}))
+
+ bwipe!
+ call prop_type_delete('test')
+ endfunc
*** ../vim-8.2.0371/src/version.c 2020-03-11 14:19:53.484369936 +0100
--- src/version.c 2020-03-11 19:10:13.319156693 +0100
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 372,
/**/

--
hundred-and-one symptoms of being an internet addict:
234. You started college as a chemistry major, and walk out four years
later as an Internet provider.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages