comparison 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
comparison
equal deleted inserted replaced
19109:a25bb65cb6d8 19110:e40814841406
662 bwipe! 662 bwipe!
663 663
664 call prop_type_delete('comment') 664 call prop_type_delete('comment')
665 endfunc 665 endfunc
666 666
667 func Test_prop_byteoff() 667 func Test_prop_line2byte()
668 call prop_type_add('comment', {'highlight': 'Directory'}) 668 call prop_type_add('comment', {'highlight': 'Directory'})
669 new 669 new
670 call setline(1, ['line1', 'second line', '']) 670 call setline(1, ['line1', 'second line', ''])
671 set ff=unix 671 set ff=unix
672 call assert_equal(19, line2byte(3)) 672 call assert_equal(19, line2byte(3))
673 call prop_add(1, 1, {'end_col': 3, 'type': 'comment'}) 673 call prop_add(1, 1, {'end_col': 3, 'type': 'comment'})
674 call assert_equal(19, line2byte(3)) 674 call assert_equal(19, line2byte(3))
675 675
676 bwipe! 676 bwipe!
677 call prop_type_delete('comment') 677 call prop_type_delete('comment')
678 endfunc
679
680 func Test_prop_byte2line()
681 new
682 set ff=unix
683 call setline(1, ['one one', 'two two', 'three three', 'four four', 'five'])
684 call assert_equal(4, byte2line(line2byte(4)))
685 call assert_equal(5, byte2line(line2byte(5)))
686
687 call prop_type_add('prop', {'highlight': 'Directory'})
688 call prop_add(3, 1, {'length': 5, 'type': 'prop'})
689 call assert_equal(4, byte2line(line2byte(4)))
690 call assert_equal(5, byte2line(line2byte(5)))
691
692 bwipe!
693 call prop_type_delete('prop')
678 endfunc 694 endfunc
679 695
680 func Test_prop_undo() 696 func Test_prop_undo()
681 new 697 new
682 call prop_type_add('comment', {'highlight': 'Directory'}) 698 call prop_type_add('comment', {'highlight': 'Directory'})