]> granicus.if.org Git - vim/commitdiff
patch 8.1.0689: undo with text properties not tested v8.1.0689
authorBram Moolenaar <Bram@vim.org>
Fri, 4 Jan 2019 16:21:24 +0000 (17:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 4 Jan 2019 16:21:24 +0000 (17:21 +0100)
Problem:    Undo with text properties not tested.
Solution:   Add a test function.

src/testdir/test_textprop.vim
src/version.c

index d251237cacb3a41223a879cd12dd79c944971574..ac9967e9498c65777696a1d4fb2e3daa25f97988 100644 (file)
@@ -348,6 +348,59 @@ func Test_prop_byteoff()
   call prop_type_delete('comment')
 endfunc
 
+func Test_prop_undo()
+  new
+  call prop_type_add('comment', {'highlight': 'Directory'})
+  call setline(1, ['oneone', 'twotwo', 'three'])
+  " Set 'undolevels' to break changes into undo-able pieces.
+  set ul&
+
+  call prop_add(1, 3, {'end_col': 5, 'type': 'comment'})
+  let expected = [{'col': 3, 'length': 2, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
+  call assert_equal(expected, prop_list(1))
+
+  " Insert a character, then undo.
+  exe "normal 0lllix\<Esc>"
+  set ul&
+  let expected[0].length = 3
+  call assert_equal(expected, prop_list(1))
+  undo
+  let expected[0].length = 2
+  call assert_equal(expected, prop_list(1))
+
+  " Delete a character, then undo
+  exe "normal 0lllx"
+  set ul&
+  let expected[0].length = 1
+  call assert_equal(expected, prop_list(1))
+  undo
+  let expected[0].length = 2
+  call assert_equal(expected, prop_list(1))
+
+  " Delete the line, then undo
+  1d
+  set ul&
+  call assert_equal([], prop_list(1))
+  undo
+  call assert_equal(expected, prop_list(1))
+
+  " Insert a character, delete two characters, then undo with "U"
+  exe "normal 0lllix\<Esc>"
+  set ul&
+  let expected[0].length = 3
+  call assert_equal(expected, prop_list(1))
+  exe "normal 0lllxx"
+  set ul&
+  let expected[0].length = 1
+  call assert_equal(expected, prop_list(1))
+  normal U
+  let expected[0].length = 2
+  call assert_equal(expected, prop_list(1))
+
+  bwipe!
+  call prop_type_delete('comment')
+endfunc
+
 " screenshot test with textprop highlighting
 funct Test_textprop_screenshots()
   if !CanRunVimInTerminal() || &encoding != 'utf-8'
index 3edb1468549710a1a2eacb2f80fcc6ffba23388f..4b7c9ae355a865eba642c6a07b313cba0cfbfcca 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    689,
 /**/
     688,
 /**/