diff src/testdir/test_textprop.vim @ 16662:1fc9cd08cf3c v8.1.1333

patch 8.1.1333: text properties don't always move after changes commit https://github.com/vim/vim/commit/45dd07f10af9bea86f8df77e92788209e209fdab Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 15 22:45:37 2019 +0200 patch 8.1.1333: text properties don't always move after changes Problem: Text properties don't always move after changes. Solution: Update properties before reporting changes to listeners. Move text property when splitting a line.
author Bram Moolenaar <Bram@vim.org>
date Wed, 15 May 2019 23:00:15 +0200
parents 7a563ee902b6
children 5733d8e33bce
line wrap: on
line diff
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -151,6 +151,7 @@ endfunc
 
 func SetupOneLine()
   call setline(1, 'xonex xtwoxx')
+  normal gg0
   call AddPropTypes()
   call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'})
   call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'})
@@ -272,6 +273,66 @@ func Test_prop_replace()
   set bs&
 endfunc
 
+func Test_prop_open_line()
+  new
+
+  " open new line, props stay in top line
+  let expected = SetupOneLine() " 'xonex xtwoxx'
+  exe "normal o\<Esc>"
+  call assert_equal('xonex xtwoxx', getline(1))
+  call assert_equal('', getline(2))
+  call assert_equal(expected, prop_list(1))
+  call DeletePropTypes()
+
+  " move all props to next line
+  let expected = SetupOneLine() " 'xonex xtwoxx'
+  exe "normal 0i\<CR>\<Esc>"
+  call assert_equal('', getline(1))
+  call assert_equal('xonex xtwoxx', getline(2))
+  call assert_equal(expected, prop_list(2))
+  call DeletePropTypes()
+
+  " split just before prop, move all props to next line
+  let expected = SetupOneLine() " 'xonex xtwoxx'
+  exe "normal 0li\<CR>\<Esc>"
+  call assert_equal('x', getline(1))
+  call assert_equal('onex xtwoxx', getline(2))
+  let expected[0].col -= 1
+  let expected[1].col -= 1
+  call assert_equal(expected, prop_list(2))
+  call DeletePropTypes()
+
+  " split inside prop, split first prop
+  let expected = SetupOneLine() " 'xonex xtwoxx'
+  exe "normal 0lli\<CR>\<Esc>"
+  call assert_equal('xo', getline(1))
+  call assert_equal('nex xtwoxx', getline(2))
+  let exp_first = [deepcopy(expected[0])]
+  let exp_first[0].length = 1
+  call assert_equal(exp_first, prop_list(1))
+  let expected[0].col = 1
+  let expected[0].length = 2
+  let expected[1].col -= 2
+  call assert_equal(expected, prop_list(2))
+  call DeletePropTypes()
+
+  " split just after first prop, empty prop and second prop move to next line
+  let expected = SetupOneLine() " 'xonex xtwoxx'
+  exe "normal 0fea\<CR>\<Esc>"
+  call assert_equal('xone', getline(1))
+  call assert_equal('x xtwoxx', getline(2))
+  let exp_first = expected[0:0]
+  call assert_equal(exp_first, prop_list(1))
+  let expected[0].col = 1
+  let expected[0].length = 0
+  let expected[1].col -= 4
+  call assert_equal(expected, prop_list(2))
+  call DeletePropTypes()
+
+  bwipe!
+  set bs&
+endfunc
+
 func Test_prop_clear()
   new
   call AddPropTypes()