aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-17 06:07:05 +0800
committerGitHub <noreply@github.com>2022-07-17 06:07:05 +0800
commit4f59bc8013a631f3bed70fb8a313e985818073f0 (patch)
tree0a7a764842acb866073ad177f5afc5bcaed3bd9c /src
parent711a6a915767a97300aba76fb9d79b9784bc76ce (diff)
parent0cfd4fa8f3dc2241de5f69d5c52510542dfc927c (diff)
downloadrneovim-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')
-rw-r--r--src/nvim/testdir/test_edit.vim39
-rw-r--r--src/nvim/testdir/test_mapping.vim10
-rw-r--r--src/nvim/testdir/test_messages.vim130
-rw-r--r--src/nvim/testdir/test_registers.vim10
-rw-r--r--src/nvim/testdir/test_termcodes.vim34
-rw-r--r--src/nvim/testdir/test_undo.vim141
6 files changed, 301 insertions, 63 deletions
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim
index 65194f49dd..69a34a1c51 100644
--- a/src/nvim/testdir/test_edit.vim
+++ b/src/nvim/testdir/test_edit.vim
@@ -420,16 +420,49 @@ func Test_edit_13()
call assert_equal("", getline(2))
call assert_equal(" baz", getline(3))
set autoindent&
+
+ " pressing <C-U> to erase line should keep the indent with 'autoindent'
+ set backspace=2 autoindent
+ %d
+ exe "normal i\tone\<CR>three\<C-U>two"
+ call assert_equal(["\tone", "\ttwo"], getline(1, '$'))
+ set backspace& autoindent&
+
bwipe!
endfunc
+" Test for autoindent removing indent when insert mode is stopped. Some parts
+" of the code is exercised only when interactive mode is used. So use Vim in a
+" terminal.
+func Test_autoindent_remove_indent()
+ CheckRunVimInTerminal
+ let buf = RunVimInTerminal('-N Xfile', {'rows': 6, 'cols' : 20})
+ call TermWait(buf)
+ call term_sendkeys(buf, ":set autoindent\n")
+ " leaving insert mode in a new line with indent added by autoindent, should
+ " remove the indent.
+ call term_sendkeys(buf, "i\<Tab>foo\<CR>\<Esc>")
+ " Need to delay for sometime, otherwise the code in getchar.c will not be
+ " exercised.
+ call TermWait(buf, 50)
+ " when a line is wrapped and the cursor is at the start of the second line,
+ " leaving insert mode, should move the cursor back to the first line.
+ call term_sendkeys(buf, "o" .. repeat('x', 20) .. "\<Esc>")
+ " Need to delay for sometime, otherwise the code in getchar.c will not be
+ " exercised.
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, ":w\n")
+ call TermWait(buf)
+ call StopVimInTerminal(buf)
+ call assert_equal(["\tfoo", '', repeat('x', 20)], readfile('Xfile'))
+ call delete('Xfile')
+endfunc
+
func Test_edit_CR()
" Test for <CR> in insert mode
" basically only in quickfix mode ist tested, the rest
" has been taken care of by other tests
- if !has("quickfix")
- return
- endif
+ CheckFeature quickfix
botright new
call writefile(range(1, 10), 'Xqflist.txt')
call setqflist([{'filename': 'Xqflist.txt', 'lnum': 2}])
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index a34a950526..e1d0b9a9ba 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -956,6 +956,16 @@ func Test_map_cmdkey_redo()
ounmap i-
endfunc
+" Test for using <script> with a map to remap characters in rhs
+func Test_script_local_remap()
+ new
+ inoremap <buffer> <SID>xyz mno
+ inoremap <buffer> <script> abc st<SID>xyzre
+ normal iabc
+ call assert_equal('stmnore', getline(1))
+ bwipe!
+endfunc
+
func Test_abbreviate_multi_byte()
new
iabbrev foo bar
diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim
index 8be0c79499..5670368936 100644
--- a/src/nvim/testdir/test_messages.vim
+++ b/src/nvim/testdir/test_messages.vim
@@ -112,6 +112,136 @@ func Test_echospace()
set ruler& showcmd&
endfunc
+" Test more-prompt (see :help more-prompt).
+func Test_message_more()
+ CheckRunVimInTerminal
+ let buf = RunVimInTerminal('', {'rows': 6})
+ call term_sendkeys(buf, ":call setline(1, range(1, 100))\n")
+
+ call term_sendkeys(buf, ":%p#\n")
+ call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
+
+ call term_sendkeys(buf, '?')
+ call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit ', term_getline(buf, 6))})
+
+ " Down a line with j, <CR>, <NL> or <Down>.
+ call term_sendkeys(buf, "j")
+ call WaitForAssert({-> assert_equal(' 6 6', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
+ call term_sendkeys(buf, "\<NL>")
+ call WaitForAssert({-> assert_equal(' 7 7', term_getline(buf, 5))})
+ call term_sendkeys(buf, "\<CR>")
+ call WaitForAssert({-> assert_equal(' 8 8', term_getline(buf, 5))})
+ call term_sendkeys(buf, "\<Down>")
+ call WaitForAssert({-> assert_equal(' 9 9', term_getline(buf, 5))})
+
+ " Down a screen with <Space>, f, or <PageDown>.
+ call term_sendkeys(buf, 'f')
+ call WaitForAssert({-> assert_equal(' 14 14', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
+ call term_sendkeys(buf, ' ')
+ call WaitForAssert({-> assert_equal(' 19 19', term_getline(buf, 5))})
+ call term_sendkeys(buf, "\<PageDown>")
+ call WaitForAssert({-> assert_equal(' 24 24', term_getline(buf, 5))})
+
+ " Down a page (half a screen) with d.
+ call term_sendkeys(buf, 'd')
+ call WaitForAssert({-> assert_equal(' 27 27', term_getline(buf, 5))})
+
+ " Down all the way with 'G'.
+ call term_sendkeys(buf, 'G')
+ call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
+
+ " Up a line k, <BS> or <Up>.
+ call term_sendkeys(buf, 'k')
+ call WaitForAssert({-> assert_equal(' 99 99', term_getline(buf, 5))})
+ call term_sendkeys(buf, "\<BS>")
+ call WaitForAssert({-> assert_equal(' 98 98', term_getline(buf, 5))})
+ call term_sendkeys(buf, "\<Up>")
+ call WaitForAssert({-> assert_equal(' 97 97', term_getline(buf, 5))})
+
+ " Up a screen with b or <PageUp>.
+ call term_sendkeys(buf, 'b')
+ call WaitForAssert({-> assert_equal(' 92 92', term_getline(buf, 5))})
+ call term_sendkeys(buf, "\<PageUp>")
+ call WaitForAssert({-> assert_equal(' 87 87', term_getline(buf, 5))})
+
+ " Up a page (half a screen) with u.
+ call term_sendkeys(buf, 'u')
+ call WaitForAssert({-> assert_equal(' 84 84', term_getline(buf, 5))})
+
+ " Up all the way with 'g'.
+ call term_sendkeys(buf, 'g')
+ call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
+
+ " All the way down. Pressing f should do nothing but pressing
+ " space should end the more prompt.
+ call term_sendkeys(buf, 'G')
+ call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
+ call term_sendkeys(buf, 'f')
+ call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
+ call term_sendkeys(buf, ' ')
+ call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))})
+
+ " Pressing g< shows the previous command output.
+ call term_sendkeys(buf, 'g<')
+ call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
+
+ call term_sendkeys(buf, ":%p#\n")
+ call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))})
+ call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
+
+ " Stop command output with q, <Esc> or CTRL-C.
+ call term_sendkeys(buf, 'q')
+ call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))})
+
+ " Execute a : command from the more prompt
+ call term_sendkeys(buf, ":%p#\n")
+ call term_wait(buf)
+ call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
+ call term_sendkeys(buf, ":")
+ call term_wait(buf)
+ call WaitForAssert({-> assert_equal(':', term_getline(buf, 6))})
+ call term_sendkeys(buf, "echo 'Hello'\n")
+ call term_wait(buf)
+ call WaitForAssert({-> assert_equal('Hello ', term_getline(buf, 5))})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_ask_yesno()
+ CheckRunVimInTerminal
+ let buf = RunVimInTerminal('', {'rows': 6})
+ call term_sendkeys(buf, ":call setline(1, range(1, 2))\n")
+
+ call term_sendkeys(buf, ":2,1s/^/n/\n")
+ call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))})
+ call term_sendkeys(buf, "n")
+ call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))})
+ call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))})
+
+ call term_sendkeys(buf, ":2,1s/^/Esc/\n")
+ call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))})
+ call term_sendkeys(buf, "\<Esc>")
+ call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))})
+ call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))})
+
+ call term_sendkeys(buf, ":2,1s/^/y/\n")
+ call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))})
+ call term_sendkeys(buf, "y")
+ call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?y *2,1 *All$', term_getline(buf, 6))})
+ call WaitForAssert({-> assert_equal('y1', term_getline(buf, 1))})
+ call WaitForAssert({-> assert_equal('y2', term_getline(buf, 2))})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_mapping_at_hit_return_prompt()
nnoremap <C-B> :echo "hit ctrl-b"<CR>
call feedkeys(":ls\<CR>", "xt")
diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim
index abe28b77cd..52e745438d 100644
--- a/src/nvim/testdir/test_registers.vim
+++ b/src/nvim/testdir/test_registers.vim
@@ -684,6 +684,16 @@ func Test_insert_small_delete()
bwipe!
endfunc
+" Record in insert mode using CTRL-O
+func Test_record_in_insert_mode()
+ new
+ let @r = ''
+ call setline(1, ['foo'])
+ call feedkeys("i\<C-O>qrbaz\<C-O>q", 'xt')
+ call assert_equal('baz', @r)
+ bwipe!
+endfunc
+
func Test_record_in_select_mode()
new
call setline(1, 'text')
diff --git a/src/nvim/testdir/test_termcodes.vim b/src/nvim/testdir/test_termcodes.vim
index f3b10a922e..c0712aa892 100644
--- a/src/nvim/testdir/test_termcodes.vim
+++ b/src/nvim/testdir/test_termcodes.vim
@@ -1,4 +1,38 @@
+" Test for terminal keycodes that doesn't have termcap entries
+func Test_special_term_keycodes()
+ new
+ " Test for <xHome>, <S-xHome> and <C-xHome>
+ " send <K_SPECIAL> <KS_EXTRA> keycode
+ call feedkeys("i\<C-K>\x80\xfd\x3f\n", 'xt')
+ " send <K_SPECIAL> <KS_MODIFIER> bitmap <K_SPECIAL> <KS_EXTRA> keycode
+ call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3f\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3f\n", 'xt')
+ " Test for <xEnd>, <S-xEnd> and <C-xEnd>
+ call feedkeys("i\<C-K>\x80\xfd\x3d\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3d\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3d\n", 'xt')
+ " Test for <zHome>, <S-zHome> and <C-zHome>
+ call feedkeys("i\<C-K>\x80\xfd\x40\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x40\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x40\n", 'xt')
+ " Test for <zEnd>, <S-zEnd> and <C-zEnd>
+ call feedkeys("i\<C-K>\x80\xfd\x3e\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3e\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3e\n", 'xt')
+ " Test for <xUp>, <xDown>, <xLeft> and <xRight>
+ call feedkeys("i\<C-K>\x80\xfd\x41\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfd\x42\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfd\x43\n", 'xt')
+ call feedkeys("i\<C-K>\x80\xfd\x44\n", 'xt')
+ call assert_equal(['<Home>', '<S-Home>', '<C-Home>',
+ \ '<End>', '<S-End>', '<C-End>',
+ \ '<Home>', '<S-Home>', '<C-Home>',
+ \ '<End>', '<S-End>', '<C-End>',
+ \ '<Up>', '<Down>', '<Left>', '<Right>', ''], getline(1, '$'))
+ bw!
+endfunc
+
func Test_simplify_ctrl_at()
" feeding unsimplified CTRL-@ should still trigger i_CTRL-@
call feedkeys("ifoo\<Esc>A\<*C-@>x", 'xt')
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.