diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-07-17 06:07:05 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-17 06:07:05 +0800 |
| commit | 4f59bc8013a631f3bed70fb8a313e985818073f0 (patch) | |
| tree | 0a7a764842acb866073ad177f5afc5bcaed3bd9c /src/nvim/testdir/test_undo.vim | |
| parent | 711a6a915767a97300aba76fb9d79b9784bc76ce (diff) | |
| parent | 0cfd4fa8f3dc2241de5f69d5c52510542dfc927c (diff) | |
| download | rneovim-4f59bc8013a631f3bed70fb8a313e985818073f0.tar.gz rneovim-4f59bc8013a631f3bed70fb8a313e985818073f0.tar.bz2 rneovim-4f59bc8013a631f3bed70fb8a313e985818073f0.zip | |
Merge pull request #19391 from zeertzjq/vim-8.2.0052
vim-patch:8.2.{0052,0198,2608,2643}: code not fully tested
Diffstat (limited to 'src/nvim/testdir/test_undo.vim')
| -rw-r--r-- | src/nvim/testdir/test_undo.vim | 141 |
1 files changed, 81 insertions, 60 deletions
diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim index da8bf12318..a9ec405aa4 100644 --- a/src/nvim/testdir/test_undo.vim +++ b/src/nvim/testdir/test_undo.vim @@ -3,8 +3,6 @@ " undo-able pieces. Do that by setting 'undolevels'. " Also tests :earlier and :later. -source check.vim - func Test_undotree() new @@ -137,8 +135,7 @@ func BackOne(expected) endfunc func Test_undo_del_chars() - CheckFunction test_settime - + throw 'Skipped: Nvim does not support test_settime()' " Setup a buffer without creating undo entries new set ul=-1 @@ -334,8 +331,9 @@ func Test_insert_expr() endfunc func Test_undofile_earlier() - CheckFunction test_settime - + throw 'Skipped: Nvim does not support test_settime()' + " Issue #1254 + " create undofile with timestamps older than Vim startup time. let t0 = localtime() - 43200 call test_settime(t0) new Xfile @@ -368,7 +366,7 @@ func Test_wundo_errors() bwipe! endfunc -" Check that reading a truncted undo file doesn't hang. +" Check that reading a truncated undo file doesn't hang. func Test_undofile_truncated() new call setline(1, 'hello') @@ -431,6 +429,59 @@ func Test_cmd_in_reg_undo() let @a = '' endfunc +" This used to cause an illegal memory access +func Test_undo_append() + new + call feedkeys("axx\<Esc>v", 'xt') + undo + norm o + quit +endfunc + +func Test_undo_0() + new + set ul=100 + normal i1 + undo + normal i2 + undo + normal i3 + + undo 0 + let d = undotree() + call assert_equal('', getline(1)) + call assert_equal(0, d.seq_cur) + + redo + let d = undotree() + call assert_equal('3', getline(1)) + call assert_equal(3, d.seq_cur) + + undo 2 + undo 0 + let d = undotree() + call assert_equal('', getline(1)) + call assert_equal(0, d.seq_cur) + + redo + let d = undotree() + call assert_equal('2', getline(1)) + call assert_equal(2, d.seq_cur) + + undo 1 + undo 0 + let d = undotree() + call assert_equal('', getline(1)) + call assert_equal(0, d.seq_cur) + + redo + let d = undotree() + call assert_equal('1', getline(1)) + call assert_equal(1, d.seq_cur) + + bwipe! +endfunc + " undo or redo are noop if there is nothing to undo or redo func Test_undo_redo_noop() new @@ -456,15 +507,6 @@ func Test_redo_empty_line() bwipe! endfunc -" This used to cause an illegal memory access -func Test_undo_append() - new - call feedkeys("axx\<Esc>v", 'xt') - undo - norm o - quit -endfunc - funct Test_undofile() " Test undofile() without setting 'undodir'. if has('persistent_undo') @@ -506,50 +548,6 @@ funct Test_undofile() set undodir& endfunc -func Test_undo_0() - new - set ul=100 - normal i1 - undo - normal i2 - undo - normal i3 - - undo 0 - let d = undotree() - call assert_equal('', getline(1)) - call assert_equal(0, d.seq_cur) - - redo - let d = undotree() - call assert_equal('3', getline(1)) - call assert_equal(3, d.seq_cur) - - undo 2 - undo 0 - let d = undotree() - call assert_equal('', getline(1)) - call assert_equal(0, d.seq_cur) - - redo - let d = undotree() - call assert_equal('2', getline(1)) - call assert_equal(2, d.seq_cur) - - undo 1 - undo 0 - let d = undotree() - call assert_equal('', getline(1)) - call assert_equal(0, d.seq_cur) - - redo - let d = undotree() - call assert_equal('1', getline(1)) - call assert_equal(1, d.seq_cur) - - bwipe! -endfunc - " Tests for the undo file " Explicitly break changes up in undo-able pieces by setting 'undolevels'. func Test_undofile_2() @@ -735,6 +733,29 @@ func Test_undofile_cryptmethod_blowfish2() set undofile& undolevels& cryptmethod& endfunc +" Test for redoing with incrementing numbered registers +func Test_redo_repeat_numbered_register() + new + for [i, v] in [[1, 'one'], [2, 'two'], [3, 'three'], + \ [4, 'four'], [5, 'five'], [6, 'six'], + \ [7, 'seven'], [8, 'eight'], [9, 'nine']] + exe 'let @' .. i .. '="' .. v .. '\n"' + endfor + call feedkeys('"1p.........', 'xt') + call assert_equal(['', 'one', 'two', 'three', 'four', 'five', 'six', + \ 'seven', 'eight', 'nine', 'nine'], getline(1, '$')) + bwipe! +endfunc + +" Test for redo in insert mode using CTRL-O with multibyte characters +func Test_redo_multibyte_in_insert_mode() + new + call feedkeys("a\<C-K>ft", 'xt') + call feedkeys("uiHe\<C-O>.llo", 'xt') + call assert_equal("He\ufb05llo", getline(1)) + bwipe! +endfunc + func Test_undo_mark() new " The undo is applied to the only line. |