Skip to content

Commit

Permalink
patch 9.0.0169: insufficient testing for line2byte() with text proper…
Browse files Browse the repository at this point in the history
…ties

Problem:    Insufficient testing for line2byte() with text properties.
Solution:   Add tests with a lot of text.
  • Loading branch information
brammool committed Aug 8, 2022
1 parent 2546361 commit cf85d97
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
29 changes: 29 additions & 0 deletions src/testdir/test_textprop.vim
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,30 @@ func Test_prop_multiline()
call prop_type_delete('comment')
endfunc

func Run_test_with_line2byte(add_props)
new
setlocal ff=unix
if a:add_props
call prop_type_add('textprop', #{highlight: 'Search'})
endif
for nr in range(1, 1000)
call setline(nr, 'some longer text here')
if a:add_props && nr % 17 == 0
call prop_add(nr, 13, #{type: 'textprop', length: 4})
endif
endfor
call assert_equal(21935, line2byte(998))
for nr in range(1, 1000, 7)
exe nr .. "s/longer/much more/"
endfor
call assert_equal(22364, line2byte(998))

if a:add_props
call prop_type_delete('textprop')
endif
bwipe!
endfunc

func Test_prop_line2byte()
call prop_type_add('comment', {'highlight': 'Directory'})
new
Expand Down Expand Up @@ -935,6 +959,11 @@ func Test_prop_line2byte()
call assert_equal(1489, line2byte(400))
bwipe!

" Add many lines so that the data block is split.
" With and without props should give the same result.
call Run_test_with_line2byte(0)
call Run_test_with_line2byte(1)

call prop_type_delete('comment')
endfunc

Expand Down
4 changes: 0 additions & 4 deletions src/textprop.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

/*
* Text properties implementation. See ":help text-properties".
*
* TODO:
* - Also test line2byte() with many lines, so that ml_updatechunk() is taken
* into account.
*/

#include "vim.h"
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
169,
/**/
168,
/**/
Expand Down

0 comments on commit cf85d97

Please sign in to comment.