Mercurial > vim
changeset 29657:b90b037e80be v9.0.0169
patch 9.0.0169: insufficient testing for line2byte() with text properties
Commit: https://github.com/vim/vim/commit/cf85d97bafdcc7837a77ab79cc04da189fa3dd0c
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 8 14:59:47 2022 +0100
patch 9.0.0169: insufficient testing for line2byte() with text properties
Problem: Insufficient testing for line2byte() with text properties.
Solution: Add tests with a lot of text.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 08 Aug 2022 16:00:05 +0200 |
parents | 4ae2a5b3cb04 |
children | 006939bc47b1 |
files | src/testdir/test_textprop.vim src/textprop.c src/version.c |
diffstat | 3 files changed, 31 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -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 @@ -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