mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.0363: some Normal mode commands not tested
Problem: Some Normal mode commands not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #5746)
This commit is contained in:
@@ -5258,9 +5258,18 @@ func Test_cindent_case()
|
|||||||
set cindent
|
set cindent
|
||||||
norm! f:a:
|
norm! f:a:
|
||||||
call assert_equal('case x:: // x', getline(1))
|
call assert_equal('case x:: // x', getline(1))
|
||||||
|
|
||||||
set cindent&
|
set cindent&
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for changing multiple lines (using c) with cindent
|
||||||
|
func Test_cindent_change_multline()
|
||||||
|
new
|
||||||
|
setlocal cindent
|
||||||
|
call setline(1, ['if (a)', '{', ' i = 1;', '}'])
|
||||||
|
normal! jc3jm = 2;
|
||||||
|
call assert_equal("\tm = 2;", getline(2))
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -1316,4 +1316,14 @@ func Test_cmdline_composing_chars()
|
|||||||
call assert_equal('"ゔ', @:)
|
call assert_equal('"ゔ', @:)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for normal mode commands not supported in the cmd window
|
||||||
|
func Test_cmdwin_blocked_commands()
|
||||||
|
call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:')
|
||||||
|
call assert_fails('call feedkeys("q:\<C-]>\<CR>", "xt")', 'E11:')
|
||||||
|
call assert_fails('call feedkeys("q:\<C-^>\<CR>", "xt")', 'E11:')
|
||||||
|
call assert_fails('call feedkeys("q:Q\<CR>", "xt")', 'E11:')
|
||||||
|
call assert_fails('call feedkeys("q:Z\<CR>", "xt")', 'E11:')
|
||||||
|
call assert_fails('call feedkeys("q:\<F1>\<CR>", "xt")', 'E11:')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -265,6 +265,10 @@ func Test_edit_10()
|
|||||||
call cursor(1, 4)
|
call cursor(1, 4)
|
||||||
call feedkeys("A\<s-home>start\<esc>", 'txin')
|
call feedkeys("A\<s-home>start\<esc>", 'txin')
|
||||||
call assert_equal(['startdef', 'ghi'], getline(1, '$'))
|
call assert_equal(['startdef', 'ghi'], getline(1, '$'))
|
||||||
|
" start select mode again with gv
|
||||||
|
set selectmode=cmd
|
||||||
|
call feedkeys('gvabc', 'xt')
|
||||||
|
call assert_equal('abctdef', getline(1))
|
||||||
set selectmode= keymodel=
|
set selectmode= keymodel=
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
@@ -1263,6 +1267,16 @@ func Test_edit_forbidden()
|
|||||||
catch /^Vim\%((\a\+)\)\=:E117/ " catch E117: unknown function
|
catch /^Vim\%((\a\+)\)\=:E117/ " catch E117: unknown function
|
||||||
endtry
|
endtry
|
||||||
au! InsertCharPre
|
au! InsertCharPre
|
||||||
|
" Not allowed to enter ex mode when text is locked
|
||||||
|
au InsertCharPre <buffer> :normal! gQ<CR>
|
||||||
|
let caught_e523 = 0
|
||||||
|
try
|
||||||
|
call feedkeys("ix\<esc>", 'xt')
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E523/ " catch E523
|
||||||
|
let caught_e523 = 1
|
||||||
|
endtry
|
||||||
|
call assert_equal(1, caught_e523)
|
||||||
|
au! InsertCharPre
|
||||||
" 3) edit when completion is shown
|
" 3) edit when completion is shown
|
||||||
fun! Complete(findstart, base)
|
fun! Complete(findstart, base)
|
||||||
if a:findstart
|
if a:findstart
|
||||||
|
@@ -98,4 +98,46 @@ func Test_copyindent()
|
|||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for changing multiple lines with lisp indent
|
||||||
|
func Test_lisp_indent_change_multiline()
|
||||||
|
new
|
||||||
|
setlocal lisp autoindent
|
||||||
|
call setline(1, ['(if a', ' (if b', ' (return 5)))'])
|
||||||
|
normal! jc2j(return 4))
|
||||||
|
call assert_equal(' (return 4))', getline(2))
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_lisp_indent()
|
||||||
|
new
|
||||||
|
setlocal lisp autoindent
|
||||||
|
call setline(1, ['(if a', ' ;; comment', ' \ abc', '', ' " str1\', ' " st\b', ' (return 5)'])
|
||||||
|
normal! jo;; comment
|
||||||
|
normal! jo\ abc
|
||||||
|
normal! jo;; ret
|
||||||
|
normal! jostr1"
|
||||||
|
normal! jostr2"
|
||||||
|
call assert_equal([' ;; comment', ' ;; comment', ' \ abc', ' \ abc', '', ' ;; ret', ' " str1\', ' str1"', ' " st\b', ' str2"'], getline(2, 11))
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for setting the 'indentexpr' from a modeline
|
||||||
|
func Test_modeline_indent_expr()
|
||||||
|
let modeline = &modeline
|
||||||
|
set modeline
|
||||||
|
func GetIndent()
|
||||||
|
return line('.') * 2
|
||||||
|
endfunc
|
||||||
|
call writefile(['# vim: indentexpr=GetIndent()'], 'Xfile.txt')
|
||||||
|
set modelineexpr
|
||||||
|
new Xfile.txt
|
||||||
|
call assert_equal('GetIndent()', &indentexpr)
|
||||||
|
exe "normal Oa\nb\n"
|
||||||
|
call assert_equal([' a', ' b'], getline(1, 2))
|
||||||
|
set modelineexpr&
|
||||||
|
delfunc GetIndent
|
||||||
|
let &modeline = modeline
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -115,8 +115,8 @@ func Test_normal01_keymodel()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for select mode
|
||||||
func Test_normal02_selectmode()
|
func Test_normal02_selectmode()
|
||||||
" some basic select mode tests
|
|
||||||
call Setup_NewWindow()
|
call Setup_NewWindow()
|
||||||
50
|
50
|
||||||
norm! gHy
|
norm! gHy
|
||||||
@@ -439,8 +439,12 @@ func Test_normal12_nv_error()
|
|||||||
10new
|
10new
|
||||||
call setline(1, range(1,5))
|
call setline(1, range(1,5))
|
||||||
" should not do anything, just beep
|
" should not do anything, just beep
|
||||||
exe "norm! <c-k>"
|
call assert_beeps('exe "norm! <c-k>"')
|
||||||
call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$'))
|
call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$'))
|
||||||
|
call assert_beeps('normal! G2dd')
|
||||||
|
call assert_beeps("normal! g\<C-A>")
|
||||||
|
call assert_beeps("normal! g\<C-X>")
|
||||||
|
call assert_beeps("normal! g\<C-B>")
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -1628,6 +1632,14 @@ fun! Test_normal30_changecase()
|
|||||||
throw 'Skipped: Turkish locale not available'
|
throw 'Skipped: Turkish locale not available'
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
call setline(1, ['aaaaaa', 'aaaaaa'])
|
||||||
|
normal! gg10~
|
||||||
|
call assert_equal(['AAAAAA', 'aaaaaa'], getline(1, 2))
|
||||||
|
set whichwrap+=~
|
||||||
|
normal! gg10~
|
||||||
|
call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2))
|
||||||
|
set whichwrap&
|
||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
@@ -1657,8 +1669,8 @@ fun! Test_normal31_r_cmd()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_normal32_g_cmd1()
|
|
||||||
" Test for g*, g#
|
" Test for g*, g#
|
||||||
|
func Test_normal32_g_cmd1()
|
||||||
new
|
new
|
||||||
call append(0, ['abc.x_foo', 'x_foobar.abc'])
|
call append(0, ['abc.x_foo', 'x_foobar.abc'])
|
||||||
1
|
1
|
||||||
@@ -1673,11 +1685,12 @@ func Test_normal32_g_cmd1()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G,
|
||||||
|
" gi and gI commands
|
||||||
fun! Test_normal33_g_cmd2()
|
fun! Test_normal33_g_cmd2()
|
||||||
if !has("jumplist")
|
if !has("jumplist")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
" Tests for g cmds
|
|
||||||
call Setup_NewWindow()
|
call Setup_NewWindow()
|
||||||
" Test for g`
|
" Test for g`
|
||||||
clearjumps
|
clearjumps
|
||||||
@@ -1689,6 +1702,10 @@ fun! Test_normal33_g_cmd2()
|
|||||||
call assert_equal('>', a[-1:])
|
call assert_equal('>', a[-1:])
|
||||||
call assert_equal(1, line('.'))
|
call assert_equal(1, line('.'))
|
||||||
call assert_equal('1', getline('.'))
|
call assert_equal('1', getline('.'))
|
||||||
|
call cursor(10, 1)
|
||||||
|
norm! g'a
|
||||||
|
call assert_equal('>', a[-1:])
|
||||||
|
call assert_equal(1, line('.'))
|
||||||
|
|
||||||
" Test for g; and g,
|
" Test for g; and g,
|
||||||
norm! g;
|
norm! g;
|
||||||
@@ -1730,6 +1747,12 @@ fun! Test_normal33_g_cmd2()
|
|||||||
exe "norm! G0\<c-v>4k4ly"
|
exe "norm! G0\<c-v>4k4ly"
|
||||||
exe "norm! gvood"
|
exe "norm! gvood"
|
||||||
call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'fgh', 'fgh', 'fgh', 'fgh', 'fgh'], getline(1,'$'))
|
call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'fgh', 'fgh', 'fgh', 'fgh', 'fgh'], getline(1,'$'))
|
||||||
|
" gv cannot be used in operator pending mode
|
||||||
|
call assert_beeps('normal! cgv')
|
||||||
|
" gv should beep without a previously selected visual area
|
||||||
|
new
|
||||||
|
call assert_beeps('normal! gv')
|
||||||
|
close
|
||||||
|
|
||||||
" Test for gk/gj
|
" Test for gk/gj
|
||||||
%d
|
%d
|
||||||
@@ -1770,8 +1793,17 @@ fun! Test_normal33_g_cmd2()
|
|||||||
norm! g^yl
|
norm! g^yl
|
||||||
call assert_equal(15, col('.'))
|
call assert_equal(15, col('.'))
|
||||||
call assert_equal('l', getreg(0))
|
call assert_equal('l', getreg(0))
|
||||||
|
call assert_beeps('normal 5g$')
|
||||||
|
|
||||||
norm! 2ggdd
|
" Test for g_
|
||||||
|
call assert_beeps('normal! 100g_')
|
||||||
|
call setline(2, [' foo ', ' foobar '])
|
||||||
|
normal! 2ggg_
|
||||||
|
call assert_equal(5, col('.'))
|
||||||
|
normal! 2g_
|
||||||
|
call assert_equal(8, col('.'))
|
||||||
|
|
||||||
|
norm! 2ggdG
|
||||||
$put =lineC
|
$put =lineC
|
||||||
|
|
||||||
" Test for gM
|
" Test for gM
|
||||||
@@ -1805,11 +1837,23 @@ fun! Test_normal33_g_cmd2()
|
|||||||
$put ='third line'
|
$put ='third line'
|
||||||
norm! gi another word
|
norm! gi another word
|
||||||
call assert_equal(['foobar next word another word', 'new line', 'third line'], getline(1,'$'))
|
call assert_equal(['foobar next word another word', 'new line', 'third line'], getline(1,'$'))
|
||||||
|
call setline(1, 'foobar')
|
||||||
|
normal! Ggifirst line
|
||||||
|
call assert_equal('foobarfirst line', getline(1))
|
||||||
|
" Test gi in 'virtualedit' mode with cursor after the end of the line
|
||||||
|
set virtualedit=all
|
||||||
|
call setline(1, 'foo')
|
||||||
|
exe "normal! Abar\<Right>\<Right>\<Right>\<Right>"
|
||||||
|
call setline(1, 'foo')
|
||||||
|
normal! Ggifirst line
|
||||||
|
call assert_equal('foo first line', getline(1))
|
||||||
|
set virtualedit&
|
||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for g CTRL-G
|
||||||
func Test_g_ctrl_g()
|
func Test_g_ctrl_g()
|
||||||
new
|
new
|
||||||
|
|
||||||
@@ -1883,8 +1927,8 @@ func Test_g_ctrl_g()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
fun! Test_normal34_g_cmd3()
|
|
||||||
" Test for g8
|
" Test for g8
|
||||||
|
fun! Test_normal34_g_cmd3()
|
||||||
new
|
new
|
||||||
let a=execute(':norm! 1G0g8')
|
let a=execute(':norm! 1G0g8')
|
||||||
call assert_equal("\nNUL", a)
|
call assert_equal("\nNUL", a)
|
||||||
@@ -1901,11 +1945,10 @@ fun! Test_normal34_g_cmd3()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test 8g8 which finds invalid utf8 at or after the cursor.
|
||||||
func Test_normal_8g8()
|
func Test_normal_8g8()
|
||||||
new
|
new
|
||||||
|
|
||||||
" Test 8g8 which finds invalid utf8 at or after the cursor.
|
|
||||||
|
|
||||||
" With invalid byte.
|
" With invalid byte.
|
||||||
call setline(1, "___\xff___")
|
call setline(1, "___\xff___")
|
||||||
norm! 1G08g8g
|
norm! 1G08g8g
|
||||||
@@ -1934,8 +1977,8 @@ func Test_normal_8g8()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
fun! Test_normal35_g_cmd4()
|
|
||||||
" Test for g<
|
" Test for g<
|
||||||
|
fun! Test_normal35_g_cmd4()
|
||||||
" Cannot capture its output,
|
" Cannot capture its output,
|
||||||
" probably a bug, therefore, test disabled:
|
" probably a bug, therefore, test disabled:
|
||||||
throw "Skipped: output of g< can't be tested currently"
|
throw "Skipped: output of g< can't be tested currently"
|
||||||
@@ -1944,6 +1987,7 @@ fun! Test_normal35_g_cmd4()
|
|||||||
call assert_true(!empty(b), 'failed `execute(g<)`')
|
call assert_true(!empty(b), 'failed `execute(g<)`')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for gp gP go
|
||||||
fun! Test_normal36_g_cmd5()
|
fun! Test_normal36_g_cmd5()
|
||||||
new
|
new
|
||||||
call append(0, 'abcdefghijklmnopqrstuvwxyz')
|
call append(0, 'abcdefghijklmnopqrstuvwxyz')
|
||||||
@@ -1982,8 +2026,8 @@ fun! Test_normal36_g_cmd5()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for gt and gT
|
||||||
fun! Test_normal37_g_cmd6()
|
fun! Test_normal37_g_cmd6()
|
||||||
" basic test for gt and gT
|
|
||||||
tabnew 1.txt
|
tabnew 1.txt
|
||||||
tabnew 2.txt
|
tabnew 2.txt
|
||||||
tabnew 3.txt
|
tabnew 3.txt
|
||||||
@@ -2009,8 +2053,8 @@ fun! Test_normal37_g_cmd6()
|
|||||||
call assert_fails(':tabclose', 'E784:')
|
call assert_fails(':tabclose', 'E784:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
fun! Test_normal38_nvhome()
|
|
||||||
" Test for <Home> and <C-Home> key
|
" Test for <Home> and <C-Home> key
|
||||||
|
fun! Test_normal38_nvhome()
|
||||||
new
|
new
|
||||||
call setline(1, range(10))
|
call setline(1, range(10))
|
||||||
$
|
$
|
||||||
@@ -2025,11 +2069,14 @@ fun! Test_normal38_nvhome()
|
|||||||
call assert_equal([0, 5, 1, 0, 1], getcurpos())
|
call assert_equal([0, 5, 1, 0, 1], getcurpos())
|
||||||
exe "norm! \<c-home>"
|
exe "norm! \<c-home>"
|
||||||
call assert_equal([0, 1, 1, 0, 1], getcurpos())
|
call assert_equal([0, 1, 1, 0, 1], getcurpos())
|
||||||
|
exe "norm! G\<c-kHome>"
|
||||||
|
call assert_equal([0, 1, 1, 0, 1], getcurpos())
|
||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for cw cW ce
|
||||||
fun! Test_normal39_cw()
|
fun! Test_normal39_cw()
|
||||||
" Test for cw and cW on whitespace
|
" Test for cw and cW on whitespace
|
||||||
" and cpo+=w setting
|
" and cpo+=w setting
|
||||||
@@ -2050,12 +2097,27 @@ fun! Test_normal39_cw()
|
|||||||
norm! 2gg0cwfoo
|
norm! 2gg0cwfoo
|
||||||
call assert_equal('foo', getline('.'))
|
call assert_equal('foo', getline('.'))
|
||||||
|
|
||||||
|
call setline(1, 'one; two')
|
||||||
|
call cursor(1, 1)
|
||||||
|
call feedkeys('cwvim', 'xt')
|
||||||
|
call assert_equal('vim; two', getline(1))
|
||||||
|
call feedkeys('0cWone', 'xt')
|
||||||
|
call assert_equal('one two', getline(1))
|
||||||
|
"When cursor is at the end of a word 'ce' will change until the end of the
|
||||||
|
"next word, but 'cw' will change only one character
|
||||||
|
call setline(1, 'one two')
|
||||||
|
call feedkeys('0ecwce', 'xt')
|
||||||
|
call assert_equal('once two', getline(1))
|
||||||
|
call setline(1, 'one two')
|
||||||
|
call feedkeys('0ecely', 'xt')
|
||||||
|
call assert_equal('only', getline(1))
|
||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for CTRL-\ commands
|
||||||
fun! Test_normal40_ctrl_bsl()
|
fun! Test_normal40_ctrl_bsl()
|
||||||
" Basic test for CTRL-\ commands
|
|
||||||
new
|
new
|
||||||
call append(0, 'here are some words')
|
call append(0, 'here are some words')
|
||||||
exe "norm! 1gg0a\<C-\>\<C-N>"
|
exe "norm! 1gg0a\<C-\>\<C-N>"
|
||||||
@@ -2079,9 +2141,8 @@ fun! Test_normal40_ctrl_bsl()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>= in insert mode
|
||||||
fun! Test_normal41_insert_reg()
|
fun! Test_normal41_insert_reg()
|
||||||
" Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>=
|
|
||||||
" in insert mode
|
|
||||||
new
|
new
|
||||||
set sts=2 sw=2 ts=8 tw=0
|
set sts=2 sw=2 ts=8 tw=0
|
||||||
call append(0, ["aaa\tbbb\tccc", '', '', ''])
|
call append(0, ["aaa\tbbb\tccc", '', '', ''])
|
||||||
@@ -2099,8 +2160,8 @@ fun! Test_normal41_insert_reg()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for Ctrl-D and Ctrl-U
|
||||||
func Test_normal42_halfpage()
|
func Test_normal42_halfpage()
|
||||||
" basic test for Ctrl-D and Ctrl-U
|
|
||||||
call Setup_NewWindow()
|
call Setup_NewWindow()
|
||||||
call assert_equal(5, &scroll)
|
call assert_equal(5, &scroll)
|
||||||
exe "norm! \<c-d>"
|
exe "norm! \<c-d>"
|
||||||
@@ -2136,8 +2197,8 @@ func Test_normal42_halfpage()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Tests for text object aw
|
||||||
fun! Test_normal43_textobject1()
|
fun! Test_normal43_textobject1()
|
||||||
" basic tests for text object aw
|
|
||||||
new
|
new
|
||||||
call append(0, ['foobar,eins,foobar', 'foo,zwei,foo '])
|
call append(0, ['foobar,eins,foobar', 'foo,zwei,foo '])
|
||||||
" diw
|
" diw
|
||||||
@@ -2167,8 +2228,8 @@ fun! Test_normal43_textobject1()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for is and as text objects
|
||||||
func Test_normal44_textobjects2()
|
func Test_normal44_textobjects2()
|
||||||
" basic testing for is and as text objects
|
|
||||||
new
|
new
|
||||||
call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
|
call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
|
||||||
" Test for dis - does not remove trailing whitespace
|
" Test for dis - does not remove trailing whitespace
|
||||||
@@ -2462,6 +2523,18 @@ func Test_gr_command()
|
|||||||
normal 4gro
|
normal 4gro
|
||||||
call assert_equal('ooooecond line', getline(2))
|
call assert_equal('ooooecond line', getline(2))
|
||||||
let &cpo = save_cpo
|
let &cpo = save_cpo
|
||||||
|
normal! ggvegrx
|
||||||
|
call assert_equal('xxxxx line', getline(1))
|
||||||
|
exe "normal! gggr\<C-V>122"
|
||||||
|
call assert_equal('zxxxx line', getline(1))
|
||||||
|
set virtualedit=all
|
||||||
|
normal! 15|grl
|
||||||
|
call assert_equal('zxxxx line l', getline(1))
|
||||||
|
set virtualedit&
|
||||||
|
set nomodifiable
|
||||||
|
call assert_fails('normal! grx', 'E21:')
|
||||||
|
call assert_fails('normal! gRx', 'E21:')
|
||||||
|
set modifiable&
|
||||||
enew!
|
enew!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -2659,10 +2732,11 @@ fun! Test_normal_gdollar_cmd()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_normal_gk()
|
func Test_normal_gk_gj()
|
||||||
" needs 80 column new window
|
" needs 80 column new window
|
||||||
new
|
new
|
||||||
vert 80new
|
vert 80new
|
||||||
|
call assert_beeps('normal gk')
|
||||||
put =[repeat('x',90)..' {{{1', 'x {{{1']
|
put =[repeat('x',90)..' {{{1', 'x {{{1']
|
||||||
norm! gk
|
norm! gk
|
||||||
" In a 80 column wide terminal the window will be only 78 char
|
" In a 80 column wide terminal the window will be only 78 char
|
||||||
@@ -2677,12 +2751,12 @@ func Test_normal_gk()
|
|||||||
norm! gk
|
norm! gk
|
||||||
call assert_equal(95, col('.'))
|
call assert_equal(95, col('.'))
|
||||||
call assert_equal(95, virtcol('.'))
|
call assert_equal(95, virtcol('.'))
|
||||||
bw!
|
%bw!
|
||||||
bw!
|
|
||||||
|
|
||||||
" needs 80 column new window
|
" needs 80 column new window
|
||||||
new
|
new
|
||||||
vert 80new
|
vert 80new
|
||||||
|
call assert_beeps('normal gj')
|
||||||
set number
|
set number
|
||||||
set numberwidth=10
|
set numberwidth=10
|
||||||
set cpoptions+=n
|
set cpoptions+=n
|
||||||
@@ -2701,9 +2775,14 @@ func Test_normal_gk()
|
|||||||
call assert_equal(1, col('.'))
|
call assert_equal(1, col('.'))
|
||||||
norm! gj
|
norm! gj
|
||||||
call assert_equal(76, col('.'))
|
call assert_equal(76, col('.'))
|
||||||
bw!
|
" When 'nowrap' is set, gk and gj behave like k and j
|
||||||
bw!
|
set nowrap
|
||||||
set cpoptions& number& numberwidth&
|
normal! gk
|
||||||
|
call assert_equal([2, 76], [line('.'), col('.')])
|
||||||
|
normal! gj
|
||||||
|
call assert_equal([3, 76], [line('.'), col('.')])
|
||||||
|
%bw!
|
||||||
|
set cpoptions& number& numberwidth& wrap&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for cursor movement with '-' in 'cpoptions'
|
" Test for cursor movement with '-' in 'cpoptions'
|
||||||
@@ -2731,3 +2810,42 @@ func Test_normal_yank_with_excmd()
|
|||||||
call assert_equal('f', @a)
|
call assert_equal('f', @a)
|
||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for supplying a count to a normal-mode command across a cursorhold call
|
||||||
|
func Test_normal_cursorhold_with_count()
|
||||||
|
func s:cHold()
|
||||||
|
let g:cHold_Called += 1
|
||||||
|
endfunc
|
||||||
|
new
|
||||||
|
augroup normalcHoldTest
|
||||||
|
au!
|
||||||
|
au CursorHold <buffer> call s:cHold()
|
||||||
|
augroup END
|
||||||
|
let g:cHold_Called = 0
|
||||||
|
call feedkeys("3\<CursorHold>2ix", 'xt')
|
||||||
|
call assert_equal(1, g:cHold_Called)
|
||||||
|
call assert_equal(repeat('x', 32), getline(1))
|
||||||
|
augroup normalcHoldTest
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
au! normalcHoldTest
|
||||||
|
close!
|
||||||
|
delfunc s:cHold
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for using a count and a command with CTRL-W
|
||||||
|
func Test_wincmd_with_count()
|
||||||
|
call feedkeys("\<C-W>12n", 'xt')
|
||||||
|
call assert_equal(12, winheight(0))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for 'b', 'B' 'ge' and 'gE' commands
|
||||||
|
func Test_backward_motion()
|
||||||
|
normal! gg
|
||||||
|
call assert_beeps('normal! b')
|
||||||
|
call assert_beeps('normal! B')
|
||||||
|
call assert_beeps('normal! gE')
|
||||||
|
call assert_beeps('normal! ge')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -124,3 +124,15 @@ func Test_prompt_garbage_collect()
|
|||||||
delfunc MyPromptCallback
|
delfunc MyPromptCallback
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for editing the prompt buffer
|
||||||
|
func Test_prompt_buffer_edit()
|
||||||
|
new
|
||||||
|
set buftype=prompt
|
||||||
|
normal! i
|
||||||
|
call assert_beeps('normal! dd')
|
||||||
|
call assert_beeps('normal! ~')
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -301,6 +301,9 @@ func Test_replace_on_tab()
|
|||||||
call append(0, "'r'\t")
|
call append(0, "'r'\t")
|
||||||
normal gg^5lrxAy
|
normal gg^5lrxAy
|
||||||
call assert_equal("'r' x y", getline(1))
|
call assert_equal("'r' x y", getline(1))
|
||||||
|
call setline(1, 'aaaaaaaaaaaa')
|
||||||
|
exe "normal! gg2lgR\<Tab>"
|
||||||
|
call assert_equal("aa\taaaa", getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
set virtualedit=
|
set virtualedit=
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -659,7 +659,6 @@ func Test_linewise_select_mode()
|
|||||||
exe "normal GkkgH\<Del>"
|
exe "normal GkkgH\<Del>"
|
||||||
call assert_equal(['', 'b', 'c'], getline(1, '$'))
|
call assert_equal(['', 'b', 'c'], getline(1, '$'))
|
||||||
|
|
||||||
|
|
||||||
" linewise select mode: delete middle two lines
|
" linewise select mode: delete middle two lines
|
||||||
call deletebufline('', 1, '$')
|
call deletebufline('', 1, '$')
|
||||||
call append('$', ['a', 'b', 'c'])
|
call append('$', ['a', 'b', 'c'])
|
||||||
@@ -681,6 +680,15 @@ func Test_linewise_select_mode()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for blockwise select mode (g CTRL-H)
|
||||||
|
func Test_blockwise_select_mode()
|
||||||
|
new
|
||||||
|
call setline(1, ['foo', 'bar'])
|
||||||
|
call feedkeys("g\<BS>\<Right>\<Down>mm", 'xt')
|
||||||
|
call assert_equal(['mmo', 'mmr'], getline(1, '$'))
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_visual_mode_put()
|
func Test_visual_mode_put()
|
||||||
new
|
new
|
||||||
|
|
||||||
@@ -908,4 +916,57 @@ func Test_star_register()
|
|||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for using visual mode maps in select mode
|
||||||
|
func Test_select_mode_map()
|
||||||
|
new
|
||||||
|
vmap <buffer> <F2> 3l
|
||||||
|
call setline(1, 'Test line')
|
||||||
|
call feedkeys("gh\<F2>map", 'xt')
|
||||||
|
call assert_equal('map line', getline(1))
|
||||||
|
|
||||||
|
vmap <buffer> <F2> ygV
|
||||||
|
call feedkeys("0gh\<Right>\<Right>\<F2>cwabc", 'xt')
|
||||||
|
call assert_equal('abc line', getline(1))
|
||||||
|
|
||||||
|
vmap <buffer> <F2> :<C-U>let v=100<CR>
|
||||||
|
call feedkeys("gggh\<Right>\<Right>\<F2>foo", 'xt')
|
||||||
|
call assert_equal('foo line', getline(1))
|
||||||
|
|
||||||
|
" reselect the select mode using gv from a visual mode map
|
||||||
|
vmap <buffer> <F2> gv
|
||||||
|
set selectmode=cmd
|
||||||
|
call feedkeys("0gh\<F2>map", 'xt')
|
||||||
|
call assert_equal('map line', getline(1))
|
||||||
|
set selectmode&
|
||||||
|
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for changing text in visual mode with 'exclusive' selection
|
||||||
|
func Test_exclusive_selection()
|
||||||
|
new
|
||||||
|
call setline(1, ['one', 'two'])
|
||||||
|
set selection=exclusive
|
||||||
|
call feedkeys("vwcabc", 'xt')
|
||||||
|
call assert_equal('abctwo', getline(1))
|
||||||
|
call setline(1, ["\tone"])
|
||||||
|
set virtualedit=all
|
||||||
|
call feedkeys('0v2lcl', 'xt')
|
||||||
|
call assert_equal('l one', getline(1))
|
||||||
|
set virtualedit&
|
||||||
|
set selection&
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for starting visual mode with a count
|
||||||
|
" This test should be run withou any previous visual modes. So this should be
|
||||||
|
" run as a first test.
|
||||||
|
func Test_AAA_start_visual_mode_with_count()
|
||||||
|
new
|
||||||
|
call setline(1, ['aaaaaaa', 'aaaaaaa', 'aaaaaaa', 'aaaaaaa'])
|
||||||
|
normal! gg2Vy
|
||||||
|
call assert_equal("aaaaaaa\naaaaaaa\n", @")
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
363,
|
||||||
/**/
|
/**/
|
||||||
362,
|
362,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user