comparison src/testdir/test_textprop.vim @ 20583:d067be761cd7 v8.2.0845

patch 8.2.0845: text properties crossing lines not handled correctly Commit: https://github.com/vim/vim/commit/87be9be1db6b6d8fb57ef14e05f23a84e5e8bea0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 30 15:32:02 2020 +0200 patch 8.2.0845: text properties crossing lines not handled correctly Problem: Text properties crossing lines not handled correctly. Solution: When joining lines merge text properties if possible. (Axel Forsman, closes #5839, closes #5683)
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 May 2020 15:45:04 +0200
parents 2fb397573541
children 6a4806e326dd
comparison
equal deleted inserted replaced
20582:49d2f01322db 20583:d067be761cd7
458 exe "normal 0lli\<CR>\<Esc>" 458 exe "normal 0lli\<CR>\<Esc>"
459 call assert_equal('xo', getline(1)) 459 call assert_equal('xo', getline(1))
460 call assert_equal('nex xtwoxx', getline(2)) 460 call assert_equal('nex xtwoxx', getline(2))
461 let exp_first = [deepcopy(expected[0])] 461 let exp_first = [deepcopy(expected[0])]
462 let exp_first[0].length = 1 462 let exp_first[0].length = 1
463 let exp_first[0].end = 0
463 call assert_equal(exp_first, prop_list(1)) 464 call assert_equal(exp_first, prop_list(1))
464 let expected[0].col = 1 465 let expected[0].col = 1
465 let expected[0].length = 2 466 let expected[0].length = 2
467 let expected[0].start = 0
466 let expected[1].col -= 2 468 let expected[1].col -= 2
467 call assert_equal(expected, prop_list(2)) 469 call assert_equal(expected, prop_list(2))
468 call DeletePropTypes() 470 call DeletePropTypes()
469 471
470 " split just after first prop, second prop move to next line 472 " split just after first prop, second prop move to next line
573 \ copy(expected_props[0]), 575 \ copy(expected_props[0]),
574 \ copy(expected_props[2]), 576 \ copy(expected_props[2]),
575 \ copy(expected_props[3]), 577 \ copy(expected_props[3]),
576 \ ] 578 \ ]
577 let expected_props[0].length = 5 579 let expected_props[0].length = 5
580 let expected_props[0].end = 0
578 unlet expected_props[3] 581 unlet expected_props[3]
579 unlet expected_props[2] 582 unlet expected_props[2]
580 call assert_equal(expected_props, prop_list(1)) 583 call assert_equal(expected_props, prop_list(1))
581 584
582 let new_props[0].length = 6 585 let new_props[0].length = 6
586 let new_props[0].start = 0
583 let new_props[1].col = 1 587 let new_props[1].col = 1
584 let new_props[1].length = 1 588 let new_props[1].length = 1
585 let new_props[2].col = 3 589 let new_props[2].col = 3
586 call assert_equal(new_props, prop_list(2)) 590 call assert_equal(new_props, prop_list(2))
587 591
1226 call assert_fails("call prop_type_get([])", 'E474:') 1230 call assert_fails("call prop_type_get([])", 'E474:')
1227 call assert_fails("call prop_type_get('', [])", 'E474:') 1231 call assert_fails("call prop_type_get('', [])", 'E474:')
1228 call assert_fails("call prop_type_list([])", 'E715:') 1232 call assert_fails("call prop_type_list([])", 'E715:')
1229 endfunc 1233 endfunc
1230 1234
1235 func Test_split_join()
1236 new
1237 call prop_type_add('test', {'highlight': 'ErrorMsg'})
1238 call setline(1, 'just some text')
1239 call prop_add(1, 6, {'length': 4, 'type': 'test'})
1240
1241 " Split in middle of "some"
1242 execute "normal! 8|i\<CR>"
1243 call assert_equal([{'id': 0, 'col': 6, 'end': 0, 'type': 'test', 'length': 2, 'start': 1}],
1244 \ prop_list(1))
1245 call assert_equal([{'id': 0, 'col': 1, 'end': 1, 'type': 'test', 'length': 2, 'start': 0}],
1246 \ prop_list(2))
1247
1248 " Join the two lines back together
1249 normal! 1GJ
1250 call assert_equal([{'id': 0, 'col': 6, 'end': 1, 'type': 'test', 'length': 5, 'start': 1}], prop_list(1))
1251
1252 bwipe!
1253 call prop_type_delete('test')
1254 endfunc
1255
1231 " vim: shiftwidth=2 sts=2 expandtab 1256 " vim: shiftwidth=2 sts=2 expandtab