patch 8.1.0682: text properties not adjusted when backspacing replaced text
Problem: Text properties are not adjusted when backspacing replaced text.
Solution: Keep text properties on text restored in replace mode.
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 737ff20..d251237 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -145,6 +145,19 @@
bwipe!
endfunc
+func SetupOneLine()
+ call setline(1, 'xonex xtwoxx')
+ call AddPropTypes()
+ call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'})
+ call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'})
+ let expected = [
+ \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
+ \ {'col': 8, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
+ \]
+ call assert_equal(expected, prop_list(1))
+ return expected
+endfunc
+
func Test_prop_add_remove_buf()
new
let bufnr = bufnr('')
@@ -180,15 +193,7 @@
func Test_prop_backspace()
new
set bs=2
- call setline(1, 'xonex xtwoxx')
- call AddPropTypes()
- call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'})
- call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'})
- let expected = [
- \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
- \ {'col': 8, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
- \]
- call assert_equal(expected, prop_list(1))
+ let expected = SetupOneLine() " 'xonex xtwoxx'
exe "normal 0li\<BS>\<Esc>fxli\<BS>\<Esc>"
call assert_equal('one xtwoxx', getline(1))
@@ -201,6 +206,32 @@
set bs&
endfunc
+func Test_prop_replace()
+ new
+ set bs=2
+ let expected = SetupOneLine() " 'xonex xtwoxx'
+
+ exe "normal 0Ryyy\<Esc>"
+ call assert_equal('yyyex xtwoxx', getline(1))
+ call assert_equal(expected, prop_list(1))
+
+ exe "normal ftRyy\<BS>"
+ call assert_equal('yyyex xywoxx', getline(1))
+ call assert_equal(expected, prop_list(1))
+
+ exe "normal 0fwRyy\<BS>"
+ call assert_equal('yyyex xyyoxx', getline(1))
+ call assert_equal(expected, prop_list(1))
+
+ exe "normal 0foRyy\<BS>\<BS>"
+ call assert_equal('yyyex xyyoxx', getline(1))
+ call assert_equal(expected, prop_list(1))
+
+ call DeletePropTypes()
+ bwipe!
+ set bs&
+endfunc
+
func Test_prop_clear()
new
call AddPropTypes()