aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-12-15 17:34:54 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-12-16 19:38:29 -0500
commitfcd9105018828048a8460c109650f61545b489a0 (patch)
tree145ee58d3908ddeeb698d2391ea7a758d655bab2
parentad5049aa60c918dba0f1094118a09f265091f6c1 (diff)
downloadrneovim-fcd9105018828048a8460c109650f61545b489a0.tar.gz
rneovim-fcd9105018828048a8460c109650f61545b489a0.tar.bz2
rneovim-fcd9105018828048a8460c109650f61545b489a0.zip
vim-patch:8.2.0012: some undo functionality is not tested
Problem: Some undo functionality is not tested. Solution: Add a few more test cases. (Dominique Pelle, closes vim/vim#5364) https://github.com/vim/vim/commit/559b9c68fe550f3af63d42e0838622aab1ceb1b3
-rw-r--r--src/nvim/testdir/test_undo.vim54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim
index e8aaecedc3..4fd4ec4e62 100644
--- a/src/nvim/testdir/test_undo.vim
+++ b/src/nvim/testdir/test_undo.vim
@@ -241,6 +241,26 @@ func Test_undojoin()
close!
endfunc
+" undojoin not allowed after undo
+func Test_undojoin_after_undo()
+ new
+ call feedkeys("ixx\<Esc>u", 'xt')
+ call assert_fails(':undojoin', 'E790:')
+ bwipe!
+endfunc
+
+" undojoin is a noop when no change yet, or when 'undolevels' is negative
+func Test_undojoin_noop()
+ new
+ call feedkeys(":undojoin\<CR>", 'xt')
+ call assert_equal([''], getline(1, '$'))
+ setlocal undolevels=-1
+ call feedkeys("ixx\<Esc>u", 'xt')
+ call feedkeys(":undojoin\<CR>", 'xt')
+ call assert_equal(['xx'], getline(1, '$'))
+ bwipe!
+endfunc
+
func Test_undo_write()
call delete('Xtest')
split Xtest
@@ -327,6 +347,22 @@ func Test_undofile_earlier()
call delete('Xundofile')
endfunc
+func Test_wundo_errors()
+ new
+ call setline(1, 'hello')
+ call assert_fails('wundo! Xdoesnotexist/Xundofile', 'E828:')
+ bwipe!
+endfunc
+
+func Test_rundo_errors()
+ call assert_fails('rundo XfileDoesNotExist', 'E822:')
+
+ call writefile(['abc'], 'Xundofile')
+ call assert_fails('rundo Xundofile', 'E823:')
+
+ call delete('Xundofile')
+endfunc
+
" Test for undo working properly when executing commands from a register.
" Also test this in an empty buffer.
func Test_cmd_in_reg_undo()
@@ -343,6 +379,24 @@ func Test_cmd_in_reg_undo()
let @a = ''
endfunc
+" undo or redo are noop if there is nothing to undo or redo
+func Test_undo_redo_noop()
+ new
+ call assert_fails('undo 2', 'E830:')
+
+ message clear
+ undo
+ let messages = split(execute('message'), "\n")
+ call assert_equal('Already at oldest change', messages[-1])
+
+ message clear
+ redo
+ let messages = split(execute('message'), "\n")
+ call assert_equal('Already at newest change', messages[-1])
+
+ bwipe!
+endfunc
+
func Test_redo_empty_line()
new
exe "norm\x16r\x160"