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)
diff --git a/src/testdir/dumps/Test_textprop_01.dump b/src/testdir/dumps/Test_textprop_01.dump
index aabe25b..b8a50be 100644
--- a/src/testdir/dumps/Test_textprop_01.dump
+++ b/src/testdir/dumps/Test_textprop_01.dump
@@ -2,7 +2,7 @@
| +0#af5f00255&@1|2| |N+0#0000000#ffff4012|u|m|b|é|r| |1+0#4040ff13&|2|3| +0#0000000&|ä|n|d| |t|h|œ|n| |4+0#4040ff13&|¾|7|.+0#0000000&| +0&#ffffff0@46
| +8#af5f00255&@1|3| >-+8#0000000#ffff4012|x+8&#ffffff0|a+8#4040ff13&@1|x+8#0000000&|-@1|x+8#4040ff13&|b@1|x+8#0000000&|-@1|x|c+8#4040ff13&@1|x|-+8#0000000&@1|x+8#4040ff13&|d@1|x|-+8#0000000&@1| @45
| +0#af5f00255&@1|4| |/+0#40ff4011&@1| |c|o|m+0#0000000#e0e0e08@1|e|n+0#40ff4011#ffffff0|t| |w+0&#e0e0e08|i|t|h| |e+8&&|r@1|o|r| +0&#ffffff0|i|n| |i|t| +0#0000000&@43
-| +0#af5f00255&@1|5| |f+0#0000000&|i|r|s|t| |l+0&#ffff4012|i|n|e| @1|s|e|c|o|n|d| +0&#ffffff0|l|i|n|e| @1|t|h|i|r|d| |l|i|n|e| |f|o|u|r|t|h| |l+0&#ffff4012|i|n|e| +0&#ffffff0@23
+| +0#af5f00255&@1|5| |f+0#0000000&|i|r|s|t| |l+0&#ffff4012|i|n|e| @1|s|e|c|o|n|d| +0&#ffffff0|l|i|n|e| @1|t|h|i|r|d| |l|i|n|e| +0&#ffff4012|f+0&#ffffff0|o|u|r|t|h| |l+0&#ffff4012|i|n|e| +0&#ffffff0@23
|~+0#4040ff13&| @73
|~| @73
| +0#0000000&@56|3|,|1| @10|A|l@1|
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index f91597f..5dddd16 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -460,9 +460,11 @@
call assert_equal('nex xtwoxx', getline(2))
let exp_first = [deepcopy(expected[0])]
let exp_first[0].length = 1
+ let exp_first[0].end = 0
call assert_equal(exp_first, prop_list(1))
let expected[0].col = 1
let expected[0].length = 2
+ let expected[0].start = 0
let expected[1].col -= 2
call assert_equal(expected, prop_list(2))
call DeletePropTypes()
@@ -575,11 +577,13 @@
\ copy(expected_props[3]),
\ ]
let expected_props[0].length = 5
+ let expected_props[0].end = 0
unlet expected_props[3]
unlet expected_props[2]
call assert_equal(expected_props, prop_list(1))
let new_props[0].length = 6
+ let new_props[0].start = 0
let new_props[1].col = 1
let new_props[1].length = 1
let new_props[2].col = 3
@@ -1228,4 +1232,25 @@
call assert_fails("call prop_type_list([])", 'E715:')
endfunc
+func Test_split_join()
+ new
+ call prop_type_add('test', {'highlight': 'ErrorMsg'})
+ call setline(1, 'just some text')
+ call prop_add(1, 6, {'length': 4, 'type': 'test'})
+
+ " Split in middle of "some"
+ execute "normal! 8|i\<CR>"
+ call assert_equal([{'id': 0, 'col': 6, 'end': 0, 'type': 'test', 'length': 2, 'start': 1}],
+ \ prop_list(1))
+ call assert_equal([{'id': 0, 'col': 1, 'end': 1, 'type': 'test', 'length': 2, 'start': 0}],
+ \ prop_list(2))
+
+ " Join the two lines back together
+ normal! 1GJ
+ call assert_equal([{'id': 0, 'col': 6, 'end': 1, 'type': 'test', 'length': 5, 'start': 1}], prop_list(1))
+
+ bwipe!
+ call prop_type_delete('test')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab