aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-04-11 21:43:45 -0400
committerGitHub <noreply@github.com>2021-04-11 21:43:45 -0400
commit38930272009662cee1704dbb8dd0cd72260e6b05 (patch)
tree3656834701adfe25f1fb52e28afb6145061e19bd /src
parent9b77a2bf60e5190369f5ed8828d82f29e3e20ca5 (diff)
parentfa9e5ab0ea2589dac3cef14086eb54a628c19999 (diff)
downloadrneovim-38930272009662cee1704dbb8dd0cd72260e6b05.tar.gz
rneovim-38930272009662cee1704dbb8dd0cd72260e6b05.tar.bz2
rneovim-38930272009662cee1704dbb8dd0cd72260e6b05.zip
Merge pull request #14337 from janlazo/vim-8.2.0409
vim-patch:8.1.{1841,2416},8.2.{409,1920,2050}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/testdir/test_alot.vim1
-rw-r--r--src/nvim/testdir/test_alot_utf8.vim1
-rw-r--r--src/nvim/testdir/test_menu.vim6
-rw-r--r--src/nvim/testdir/test_search.vim533
-rw-r--r--src/nvim/testdir/test_shift.vim117
5 files changed, 454 insertions, 204 deletions
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim
index 71af3eead7..e50602ccad 100644
--- a/src/nvim/testdir/test_alot.vim
+++ b/src/nvim/testdir/test_alot.vim
@@ -35,6 +35,7 @@ source test_popup.vim
source test_put.vim
source test_rename.vim
source test_scroll_opt.vim
+source test_shift.vim
source test_sort.vim
source test_sha256.vim
source test_suspend.vim
diff --git a/src/nvim/testdir/test_alot_utf8.vim b/src/nvim/testdir/test_alot_utf8.vim
index be0bd01413..70f14320a6 100644
--- a/src/nvim/testdir/test_alot_utf8.vim
+++ b/src/nvim/testdir/test_alot_utf8.vim
@@ -6,7 +6,6 @@
source test_charsearch_utf8.vim
source test_expr_utf8.vim
-source test_listlbr_utf8.vim
source test_matchadd_conceal_utf8.vim
source test_mksession_utf8.vim
source test_regexp_utf8.vim
diff --git a/src/nvim/testdir/test_menu.vim b/src/nvim/testdir/test_menu.vim
index 055d944b15..de6d4aa359 100644
--- a/src/nvim/testdir/test_menu.vim
+++ b/src/nvim/testdir/test_menu.vim
@@ -11,7 +11,13 @@ func Test_load_menu()
call assert_report('error while loading menus: ' . v:exception)
endtry
call assert_match('browse confirm w', execute(':menu File.Save'))
+
+ let v:errmsg = ''
+ doautocmd LoadBufferMenu VimEnter
+ call assert_equal('', v:errmsg)
+
source $VIMRUNTIME/delmenu.vim
+ call assert_equal('', v:errmsg)
endfunc
func Test_translate_menu()
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 7aa01c61ca..75d42b986b 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -7,9 +7,8 @@ source check.vim
" See test/functional/legacy/search_spec.lua
func Test_search_cmdline()
CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
" need to disable char_avail,
" so that expansion of commandline works
call test_override("char_avail", 1)
@@ -206,9 +205,8 @@ endfunc
" See test/functional/legacy/search_spec.lua
func Test_search_cmdline2()
CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
" need to disable char_avail,
" so that expansion of commandline works
call test_override("char_avail", 1)
@@ -369,9 +367,8 @@ func Incsearch_cleanup()
endfunc
func Test_search_cmdline3()
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
call Cmdline3_prep()
1
" first match
@@ -382,9 +379,8 @@ func Test_search_cmdline3()
endfunc
func Test_search_cmdline3s()
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
call Cmdline3_prep()
1
call feedkeys(":%s/the\<c-l>/xxx\<cr>", 'tx')
@@ -408,9 +404,8 @@ func Test_search_cmdline3s()
endfunc
func Test_search_cmdline3g()
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
call Cmdline3_prep()
1
call feedkeys(":g/the\<c-l>/d\<cr>", 'tx')
@@ -431,9 +426,8 @@ func Test_search_cmdline3g()
endfunc
func Test_search_cmdline3v()
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
call Cmdline3_prep()
1
call feedkeys(":v/the\<c-l>/d\<cr>", 'tx')
@@ -450,9 +444,8 @@ endfunc
" See test/functional/legacy/search_spec.lua
func Test_search_cmdline4()
CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
" need to disable char_avail,
" so that expansion of commandline works
call test_override("char_avail", 1)
@@ -484,9 +477,8 @@ func Test_search_cmdline4()
endfunc
func Test_search_cmdline5()
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
" Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
" regardless char_avail.
new
@@ -503,6 +495,46 @@ func Test_search_cmdline5()
bw!
endfunc
+func Test_search_cmdline6()
+ " Test that consecutive matches
+ " are caught by <c-g>/<c-t>
+ CheckFunction test_override
+ CheckOption incsearch
+
+ " need to disable char_avail,
+ " so that expansion of commandline works
+ call test_override("char_avail", 1)
+ new
+ call setline(1, [' bbvimb', ''])
+ set incsearch
+ " first match
+ norm! gg0
+ call feedkeys("/b\<cr>", 'tx')
+ call assert_equal([0,1,2,0], getpos('.'))
+ " second match
+ norm! gg0
+ call feedkeys("/b\<c-g>\<cr>", 'tx')
+ call assert_equal([0,1,3,0], getpos('.'))
+ " third match
+ norm! gg0
+ call feedkeys("/b\<c-g>\<c-g>\<cr>", 'tx')
+ call assert_equal([0,1,7,0], getpos('.'))
+ " first match again
+ norm! gg0
+ call feedkeys("/b\<c-g>\<c-g>\<c-g>\<cr>", 'tx')
+ call assert_equal([0,1,2,0], getpos('.'))
+ set nowrapscan
+ " last match
+ norm! gg0
+ call feedkeys("/b\<c-g>\<c-g>\<c-g>\<cr>", 'tx')
+ call assert_equal([0,1,7,0], getpos('.'))
+ " clean up
+ set wrapscan&vim
+ set noincsearch
+ call test_override("char_avail", 0)
+ bw!
+endfunc
+
func Test_search_cmdline7()
CheckFunction test_override
" Test that pressing <c-g> in an empty command line
@@ -598,26 +630,226 @@ func Test_search_regexp()
enew!
endfunc
-" Test for search('multi-byte char', 'bce')
-func Test_search_multibyte()
- let save_enc = &encoding
- set encoding=utf8
- enew!
- call append('$', 'A')
- call cursor(2, 1)
- call assert_equal(2, search('A', 'bce', line('.')))
- enew!
- let &encoding = save_enc
+func Test_search_cmdline_incsearch_highlight()
+ CheckFunction test_override
+ CheckOption incsearch
+
+ set incsearch hlsearch
+ " need to disable char_avail,
+ " so that expansion of commandline works
+ call test_override("char_avail", 1)
+ new
+ call setline(1, ['aaa 1 the first', ' 2 the second', ' 3 the third'])
+
+ 1
+ call feedkeys("/second\<cr>", 'tx')
+ call assert_equal('second', @/)
+ call assert_equal(' 2 the second', getline('.'))
+
+ " Canceling search won't change @/
+ 1
+ let @/ = 'last pattern'
+ call feedkeys("/third\<C-c>", 'tx')
+ call assert_equal('last pattern', @/)
+ call feedkeys("/third\<Esc>", 'tx')
+ call assert_equal('last pattern', @/)
+ call feedkeys("/3\<bs>\<bs>", 'tx')
+ call assert_equal('last pattern', @/)
+ call feedkeys("/third\<c-g>\<c-t>\<Esc>", 'tx')
+ call assert_equal('last pattern', @/)
+
+ " clean up
+ set noincsearch nohlsearch
+ bw!
endfunc
-" Similar to Test_incsearch_substitute() but with a screendump halfway.
-func Test_incsearch_substitute_dump()
- if !exists('+incsearch')
+func Test_search_cmdline_incsearch_highlight_attr()
+ CheckOption incsearch
+ CheckFeature terminal
+ CheckNotGui
+
+ let h = winheight(0)
+ if h < 3
return
endif
+
+ " Prepare buffer text
+ let lines = ['abb vim vim vi', 'vimvivim']
+ call writefile(lines, 'Xsearch.txt')
+ let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
+
+ call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])})
+ " wait for vim to complete initialization
+ call term_wait(buf)
+
+ " Get attr of normal(a0), incsearch(a1), hlsearch(a2) highlight
+ call term_sendkeys(buf, ":set incsearch hlsearch\<cr>")
+ call term_sendkeys(buf, '/b')
+ call term_wait(buf, 200)
+ let screen_line1 = term_scrape(buf, 1)
+ call assert_true(len(screen_line1) > 2)
+ " a0: attr_normal
+ let a0 = screen_line1[0].attr
+ " a1: attr_incsearch
+ let a1 = screen_line1[1].attr
+ " a2: attr_hlsearch
+ let a2 = screen_line1[2].attr
+ call assert_notequal(a0, a1)
+ call assert_notequal(a0, a2)
+ call assert_notequal(a1, a2)
+ call term_sendkeys(buf, "\<cr>gg0")
+
+ " Test incremental highlight search
+ call term_sendkeys(buf, "/vim")
+ call term_wait(buf, 200)
+ " Buffer:
+ " abb vim vim vi
+ " vimvivim
+ " Search: /vim
+ let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a2,a2,a2,a0,a0,a0]
+ let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
+ call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr'))
+ call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr'))
+
+ " Test <C-g>
+ call term_sendkeys(buf, "\<C-g>\<C-g>")
+ call term_wait(buf, 200)
+ let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0]
+ let attr_line2 = [a1,a1,a1,a0,a0,a2,a2,a2]
+ call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr'))
+ call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr'))
+
+ " Test <C-t>
+ call term_sendkeys(buf, "\<C-t>")
+ call term_wait(buf, 200)
+ let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a1,a1,a1,a0,a0,a0]
+ let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
+ call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr'))
+ call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr'))
+
+ " Type Enter and a1(incsearch highlight) should become a2(hlsearch highlight)
+ call term_sendkeys(buf, "\<cr>")
+ call term_wait(buf, 200)
+ let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0]
+ let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
+ call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr'))
+ call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr'))
+
+ " Test nohlsearch. a2(hlsearch highlight) should become a0(normal highlight)
+ call term_sendkeys(buf, ":1\<cr>")
+ call term_sendkeys(buf, ":set nohlsearch\<cr>")
+ call term_sendkeys(buf, "/vim")
+ call term_wait(buf, 200)
+ let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a0,a0,a0,a0,a0,a0]
+ let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0]
+ call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr'))
+ call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr'))
+ call delete('Xsearch.txt')
+
+ call delete('Xsearch.txt')
+ bwipe!
+endfunc
+
+func Test_incsearch_cmdline_modifier()
+ CheckFunction test_override
+ CheckOption incsearch
+
+ call test_override("char_avail", 1)
+ new
+ call setline(1, ['foo'])
+ set incsearch
+ " Test that error E14 does not occur in parsing command modifier.
+ call feedkeys("V:tab", 'tx')
+
+ call Incsearch_cleanup()
+endfunc
+
+func Test_incsearch_scrolling()
if !CanRunVimInTerminal()
throw 'Skipped: cannot make screendumps'
endif
+ call assert_equal(0, &scrolloff)
+ call writefile([
+ \ 'let dots = repeat(".", 120)',
+ \ 'set incsearch cmdheight=2 scrolloff=0',
+ \ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])',
+ \ 'normal gg',
+ \ 'redraw',
+ \ ], 'Xscript')
+ let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70})
+ " Need to send one key at a time to force a redraw
+ call term_sendkeys(buf, '/')
+ sleep 100m
+ call term_sendkeys(buf, 't')
+ sleep 100m
+ call term_sendkeys(buf, 'a')
+ sleep 100m
+ call term_sendkeys(buf, 'r')
+ sleep 100m
+ call term_sendkeys(buf, 'g')
+ call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {})
+
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+ call delete('Xscript')
+endfunc
+
+func Test_incsearch_search_dump()
+ CheckOption incsearch
+ CheckScreendump
+
+ call writefile([
+ \ 'set incsearch hlsearch scrolloff=0',
+ \ 'for n in range(1, 8)',
+ \ ' call setline(n, "foo " . n)',
+ \ 'endfor',
+ \ '3',
+ \ ], 'Xis_search_script')
+ let buf = RunVimInTerminal('-S Xis_search_script', {'rows': 9, 'cols': 70})
+ " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
+ " the 'ambiwidth' check.
+ sleep 100m
+
+ " Need to send one key at a time to force a redraw.
+ call term_sendkeys(buf, '/fo')
+ call VerifyScreenDump(buf, 'Test_incsearch_search_01', {})
+ call term_sendkeys(buf, "\<Esc>")
+ sleep 100m
+
+ call term_sendkeys(buf, '/\v')
+ call VerifyScreenDump(buf, 'Test_incsearch_search_02', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call StopVimInTerminal(buf)
+ call delete('Xis_search_script')
+endfunc
+
+func Test_incsearch_substitute()
+ CheckFunction test_override
+ CheckOption incsearch
+
+ call test_override("char_avail", 1)
+ new
+ set incsearch
+ for n in range(1, 10)
+ call setline(n, 'foo ' . n)
+ endfor
+ 4
+ call feedkeys(":.,.+2s/foo\<BS>o\<BS>o/xxx\<cr>", 'tx')
+ call assert_equal('foo 3', getline(3))
+ call assert_equal('xxx 4', getline(4))
+ call assert_equal('xxx 5', getline(5))
+ call assert_equal('xxx 6', getline(6))
+ call assert_equal('foo 7', getline(7))
+
+ call Incsearch_cleanup()
+endfunc
+
+" Similar to Test_incsearch_substitute() but with a screendump halfway.
+func Test_incsearch_substitute_dump()
+ CheckOption incsearch
+ CheckScreendump
+
call writefile([
\ 'set incsearch hlsearch scrolloff=0',
\ 'for n in range(1, 10)',
@@ -724,12 +956,8 @@ func Test_incsearch_substitute_dump()
endfunc
func Test_incsearch_highlighting()
- if !exists('+incsearch')
- return
- endif
- if !CanRunVimInTerminal()
- throw 'Skipped: cannot make screendumps'
- endif
+ CheckOption incsearch
+ CheckScreendump
call writefile([
\ 'set incsearch hlsearch',
@@ -745,16 +973,40 @@ func Test_incsearch_highlighting()
call term_sendkeys(buf, ":%s;ello/the")
call VerifyScreenDump(buf, 'Test_incsearch_substitute_15', {})
call term_sendkeys(buf, "<Esc>")
+
+ call StopVimInTerminal(buf)
+ call delete('Xis_subst_hl_script')
+endfunc
+
+func Test_incsearch_with_change()
+ CheckFeature timers
+ CheckOption incsearch
+ CheckScreendump
+
+ call writefile([
+ \ 'set incsearch hlsearch scrolloff=0',
+ \ 'call setline(1, ["one", "two ------ X", "three"])',
+ \ 'call timer_start(200, { _ -> setline(2, "x")})',
+ \ ], 'Xis_change_script')
+ let buf = RunVimInTerminal('-S Xis_change_script', {'rows': 9, 'cols': 70})
+ " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
+ " the 'ambiwidth' check.
+ sleep 300m
+
+ " Highlight X, it will be deleted by the timer callback.
+ call term_sendkeys(buf, ':%s/X')
+ call VerifyScreenDump(buf, 'Test_incsearch_change_01', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call StopVimInTerminal(buf)
+ call delete('Xis_change_script')
endfunc
" Similar to Test_incsearch_substitute_dump() for :sort
func Test_incsearch_sort_dump()
- if !exists('+incsearch')
- return
- endif
- if !CanRunVimInTerminal()
- throw 'Skipped: cannot make screendumps'
- endif
+ CheckOption incsearch
+ CheckScreendump
+
call writefile([
\ 'set incsearch hlsearch scrolloff=0',
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
@@ -778,12 +1030,9 @@ endfunc
" Similar to Test_incsearch_substitute_dump() for :vimgrep famiry
func Test_incsearch_vimgrep_dump()
- if !exists('+incsearch')
- return
- endif
- if !CanRunVimInTerminal()
- throw 'Skipped: cannot make screendumps'
- endif
+ CheckOption incsearch
+ CheckScreendump
+
call writefile([
\ 'set incsearch hlsearch scrolloff=0',
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
@@ -820,9 +1069,8 @@ endfunc
func Test_keep_last_search_pattern()
CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
new
call setline(1, ['foo', 'foo', 'foo'])
set incsearch
@@ -842,9 +1090,8 @@ endfunc
func Test_word_under_cursor_after_match()
CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
new
call setline(1, 'foo bar')
set incsearch
@@ -862,9 +1109,8 @@ endfunc
func Test_subst_word_under_cursor()
CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
new
call setline(1, ['int SomeLongName;', 'for (xxx = 1; xxx < len; ++xxx)'])
set incsearch
@@ -878,130 +1124,6 @@ func Test_subst_word_under_cursor()
set noincsearch
endfunc
-func Test_incsearch_with_change()
- if !has('timers') || !exists('+incsearch') || !CanRunVimInTerminal()
- throw 'Skipped: cannot make screendumps and/or timers feature and/or incsearch option missing'
- endif
-
- call writefile([
- \ 'set incsearch hlsearch scrolloff=0',
- \ 'call setline(1, ["one", "two ------ X", "three"])',
- \ 'call timer_start(200, { _ -> setline(2, "x")})',
- \ ], 'Xis_change_script')
- let buf = RunVimInTerminal('-S Xis_change_script', {'rows': 9, 'cols': 70})
- " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
- " the 'ambiwidth' check.
- sleep 300m
-
- " Highlight X, it will be deleted by the timer callback.
- call term_sendkeys(buf, ':%s/X')
- call VerifyScreenDump(buf, 'Test_incsearch_change_01', {})
- call term_sendkeys(buf, "\<Esc>")
-
- call StopVimInTerminal(buf)
- call delete('Xis_change_script')
-endfunc
-
-func Test_incsearch_cmdline_modifier()
- CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
- call test_override("char_avail", 1)
- new
- call setline(1, ['foo'])
- set incsearch
- " Test that error E14 does not occur in parsing command modifier.
- call feedkeys("V:tab", 'tx')
-
- call Incsearch_cleanup()
-endfunc
-
-func Test_incsearch_scrolling()
- if !CanRunVimInTerminal()
- return
- endif
- call assert_equal(0, &scrolloff)
- call writefile([
- \ 'let dots = repeat(".", 120)',
- \ 'set incsearch cmdheight=2 scrolloff=0',
- \ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])',
- \ 'normal gg',
- \ 'redraw',
- \ ], 'Xscript')
- let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70})
- " Need to send one key at a time to force a redraw
- call term_sendkeys(buf, '/')
- sleep 100m
- call term_sendkeys(buf, 't')
- sleep 100m
- call term_sendkeys(buf, 'a')
- sleep 100m
- call term_sendkeys(buf, 'r')
- sleep 100m
- call term_sendkeys(buf, 'g')
- call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {})
-
- call term_sendkeys(buf, "\<Esc>")
- call StopVimInTerminal(buf)
- call delete('Xscript')
-endfunc
-
-func Test_incsearch_search_dump()
- if !exists('+incsearch')
- return
- endif
- if !CanRunVimInTerminal()
- return
- endif
- call writefile([
- \ 'set incsearch hlsearch scrolloff=0',
- \ 'for n in range(1, 8)',
- \ ' call setline(n, "foo " . n)',
- \ 'endfor',
- \ '3',
- \ ], 'Xis_search_script')
- let buf = RunVimInTerminal('-S Xis_search_script', {'rows': 9, 'cols': 70})
- " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
- " the 'ambiwidth' check.
- sleep 100m
-
- " Need to send one key at a time to force a redraw.
- call term_sendkeys(buf, '/fo')
- call VerifyScreenDump(buf, 'Test_incsearch_search_01', {})
- call term_sendkeys(buf, "\<Esc>")
- sleep 100m
-
- call term_sendkeys(buf, '/\v')
- call VerifyScreenDump(buf, 'Test_incsearch_search_02', {})
- call term_sendkeys(buf, "\<Esc>")
-
- call StopVimInTerminal(buf)
- call delete('Xis_search_script')
-endfunc
-
-func Test_incsearch_substitute()
- CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
- call test_override("char_avail", 1)
- new
- set incsearch
- for n in range(1, 10)
- call setline(n, 'foo ' . n)
- endfor
- 4
- call feedkeys(":.,.+2s/foo\<BS>o\<BS>o/xxx\<cr>", 'tx')
- call assert_equal('foo 3', getline(3))
- call assert_equal('xxx 4', getline(4))
- call assert_equal('xxx 5', getline(5))
- call assert_equal('xxx 6', getline(6))
- call assert_equal('foo 7', getline(7))
-
- call Incsearch_cleanup()
-endfunc
-
func Test_incsearch_substitute_long_line()
CheckFunction test_override
new
@@ -1018,9 +1140,8 @@ func Test_incsearch_substitute_long_line()
endfunc
func Test_search_undefined_behaviour()
- if !has("terminal")
- return
- endif
+ CheckFeature terminal
+
let h = winheight(0)
if h < 3
return
@@ -1036,6 +1157,18 @@ func Test_search_undefined_behaviour2()
call search("\%UC0000000")
endfunc
+" Test for search('multi-byte char', 'bce')
+func Test_search_multibyte()
+ let save_enc = &encoding
+ set encoding=utf8
+ enew!
+ call append('$', 'A')
+ call cursor(2, 1)
+ call assert_equal(2, search('A', 'bce', line('.')))
+ enew!
+ let &encoding = save_enc
+endfunc
+
" This was causing E874. Also causes an invalid read?
func Test_look_behind()
new
@@ -1074,9 +1207,8 @@ func Test_search_Ctrl_L_combining()
" ' ̇' U+0307 Dec:775 COMBINING DOT ABOVE &#x307; /\%u307\Z "\u0307"
" ' ̣' U+0323 Dec:803 COMBINING DOT BELOW &#x323; /\%u323 "\u0323"
" Those should also appear on the commandline
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
call Cmdline3_prep()
1
let bufcontent = ['', 'Miạ̀́̇m']
@@ -1126,9 +1258,8 @@ endfunc
func Test_incsearch_add_char_under_cursor()
CheckFunction test_override
- if !exists('+incsearch')
- return
- endif
+ CheckOption incsearch
+
set incsearch
new
call setline(1, ['find match', 'anything'])
@@ -1213,7 +1344,7 @@ func Test_search_smartcase_utf8()
close!
endfunc
-func Test_zzzz_incsearch_highlighting_newline()
+func Test_incsearch_highlighting_newline()
CheckRunVimInTerminal
CheckOption incsearch
CheckScreendump
@@ -1226,20 +1357,16 @@ func Test_zzzz_incsearch_highlighting_newline()
[CODE]
call writefile(commands, 'Xincsearch_nl')
let buf = RunVimInTerminal('-S Xincsearch_nl', {'rows': 5, 'cols': 10})
- " Need to send one key at a time to force a redraw
call term_sendkeys(buf, '/test')
- sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline1', {})
+ " Need to send one key at a time to force a redraw
call term_sendkeys(buf, '\n')
- sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline2', {})
call term_sendkeys(buf, 'x')
- sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline3', {})
call term_sendkeys(buf, 'x')
call VerifyScreenDump(buf, 'Test_incsearch_newline4', {})
call term_sendkeys(buf, "\<CR>")
- sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline5', {})
call StopVimInTerminal(buf)
diff --git a/src/nvim/testdir/test_shift.vim b/src/nvim/testdir/test_shift.vim
new file mode 100644
index 0000000000..ec357dac88
--- /dev/null
+++ b/src/nvim/testdir/test_shift.vim
@@ -0,0 +1,117 @@
+" Test shifting lines with :> and :<
+
+source check.vim
+
+func Test_ex_shift_right()
+ set shiftwidth=2
+
+ " shift right current line.
+ call setline(1, range(1, 5))
+ 2
+ >
+ 3
+ >>
+ call assert_equal(['1',
+ \ ' 2',
+ \ ' 3',
+ \ '4',
+ \ '5'], getline(1, '$'))
+
+ " shift right with range.
+ call setline(1, range(1, 4))
+ 2,3>>
+ call assert_equal(['1',
+ \ ' 2',
+ \ ' 3',
+ \ '4',
+ \ '5'], getline(1, '$'))
+
+ " shift right with range and count.
+ call setline(1, range(1, 4))
+ 2>3
+ call assert_equal(['1',
+ \ ' 2',
+ \ ' 3',
+ \ ' 4',
+ \ '5'], getline(1, '$'))
+
+ bw!
+ set shiftwidth&
+endfunc
+
+func Test_ex_shift_left()
+ set shiftwidth=2
+
+ call setline(1, range(1, 5))
+ %>>>
+
+ " left shift current line.
+ 2<
+ 3<<
+ 4<<<<<
+ call assert_equal([' 1',
+ \ ' 2',
+ \ ' 3',
+ \ '4',
+ \ ' 5'], getline(1, '$'))
+
+ " shift right with range.
+ call setline(1, range(1, 5))
+ %>>>
+ 2,3<<
+ call assert_equal([' 1',
+ \ ' 2',
+ \ ' 3',
+ \ ' 4',
+ \ ' 5'], getline(1, '$'))
+
+ " shift right with range and count.
+ call setline(1, range(1, 5))
+ %>>>
+ 2<<3
+ call assert_equal([' 1',
+ \ ' 2',
+ \ ' 3',
+ \ ' 4',
+ \ ' 5'], getline(1, '$'))
+
+ bw!
+ set shiftwidth&
+endfunc
+
+func Test_ex_shift_rightleft()
+ CheckFeature rightleft
+
+ set shiftwidth=2 rightleft
+
+ call setline(1, range(1, 4))
+ 2,3<<
+ call assert_equal(['1',
+ \ ' 2',
+ \ ' 3',
+ \ '4'], getline(1, '$'))
+
+ 3,4>
+ call assert_equal(['1',
+ \ ' 2',
+ \ ' 3',
+ \ '4'], getline(1, '$'))
+
+ bw!
+ set rightleft& shiftwidth&
+endfunc
+
+func Test_ex_shift_errors()
+ call assert_fails('><', 'E488:')
+ call assert_fails('<>', 'E488:')
+
+ call assert_fails('>!', 'E477:')
+ call assert_fails('<!', 'E477:')
+
+ " call assert_fails('2,1>', 'E493:')
+ call assert_fails('execute "2,1>"', 'E493:')
+ " call assert_fails('2,1<', 'E493:')
+ call assert_fails('execute "2,1<"', 'E493:')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab