diff src/testdir/test_textprop.vim @ 19110:e40814841406 v8.2.0115

patch 8.2.0115: byte2line() does not work correctly with text properties Commit: https://github.com/vim/vim/commit/9df53b62de86f544b41bef5e964b7fc8ae5231e3 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 13 20:40:51 2020 +0100 patch 8.2.0115: byte2line() does not work correctly with text properties Problem: Byte2line() does not work correctly with text properties. (Billie Cleek) Solution: Take the bytes of the text properties into account. (closes #5334)
author Bram Moolenaar <Bram@vim.org>
date Mon, 13 Jan 2020 20:45:03 +0100
parents 91bb12995034
children 36ec10251b2b
line wrap: on
line diff
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -664,7 +664,7 @@ func Test_prop_multiline()
   call prop_type_delete('comment')
 endfunc
 
-func Test_prop_byteoff()
+func Test_prop_line2byte()
   call prop_type_add('comment', {'highlight': 'Directory'})
   new
   call setline(1, ['line1', 'second line', ''])
@@ -677,6 +677,22 @@ func Test_prop_byteoff()
   call prop_type_delete('comment')
 endfunc
 
+func Test_prop_byte2line()
+  new
+  set ff=unix
+  call setline(1, ['one one', 'two two', 'three three', 'four four', 'five'])
+  call assert_equal(4, byte2line(line2byte(4)))
+  call assert_equal(5, byte2line(line2byte(5)))
+
+  call prop_type_add('prop', {'highlight': 'Directory'})
+  call prop_add(3, 1, {'length': 5, 'type': 'prop'})
+  call assert_equal(4, byte2line(line2byte(4)))
+  call assert_equal(5, byte2line(line2byte(5)))
+
+  bwipe!
+  call prop_type_delete('prop')
+endfunc
+
 func Test_prop_undo()
   new
   call prop_type_add('comment', {'highlight': 'Directory'})