To: vim_dev@googlegroups.com Subject: Patch 9.0.0169 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0169 Problem: Insufficient testing for line2byte() with text properties. Solution: Add tests with a lot of text. Files: src/textprop.c, src/testdir/test_textprop.vim *** ../vim-9.0.0168/src/textprop.c 2022-08-07 22:04:53.687700914 +0100 --- src/textprop.c 2022-08-08 14:25:58.737922679 +0100 *************** *** 9,18 **** /* * 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" --- 9,14 ---- *** ../vim-9.0.0168/src/testdir/test_textprop.vim 2022-08-08 11:07:25.268222468 +0100 --- src/testdir/test_textprop.vim 2022-08-08 14:59:16.273992370 +0100 *************** *** 904,909 **** --- 904,933 ---- 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,940 **** --- 959,969 ---- 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 *** ../vim-9.0.0168/src/version.c 2022-08-08 11:07:25.268222468 +0100 --- src/version.c 2022-08-08 14:59:26.205990571 +0100 *************** *** 737,738 **** --- 737,740 ---- { /* Add new patch number below this line */ + /**/ + 169, /**/ -- We're knights of the round table We dance whene'er we're able We do routines and chorus scenes With footwork impeccable. We dine well here in Camelot We eat ham and jam and spam a lot. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///