diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-04 17:21:24 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-04 17:21:24 +0100 |
commit | 7f1664e392388fd38c8b154389167ad1bdedff66 (patch) | |
tree | 67dfd4e63985d7680fd105fde54fca78f3ecdbcc /src/testdir/test_textprop.vim | |
parent | ccae4672fd622f2feac8322be71b6e43e68dc4fc (diff) | |
download | vim-git-8.1.0689.tar.gz |
patch 8.1.0689: undo with text properties not testedv8.1.0689
Problem: Undo with text properties not tested.
Solution: Add a test function.
Diffstat (limited to 'src/testdir/test_textprop.vim')
-rw-r--r-- | src/testdir/test_textprop.vim | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index d251237ca..ac9967e94 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -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' |