mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 08:28:34 +00:00
vim-patch:8.2.0409: search test leaves file behind
Problem: Search test leaves file behind.
Solution: Delete the file. Also use Check commands.
b68df220c5
Reorder tests based on test_search.vim in patch v8.2.0409.
This commit is contained in:
@@ -7,9 +7,8 @@ source check.vim
|
|||||||
" See test/functional/legacy/search_spec.lua
|
" See test/functional/legacy/search_spec.lua
|
||||||
func Test_search_cmdline()
|
func Test_search_cmdline()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
" need to disable char_avail,
|
" need to disable char_avail,
|
||||||
" so that expansion of commandline works
|
" so that expansion of commandline works
|
||||||
call test_override("char_avail", 1)
|
call test_override("char_avail", 1)
|
||||||
@@ -206,9 +205,8 @@ endfunc
|
|||||||
" See test/functional/legacy/search_spec.lua
|
" See test/functional/legacy/search_spec.lua
|
||||||
func Test_search_cmdline2()
|
func Test_search_cmdline2()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
" need to disable char_avail,
|
" need to disable char_avail,
|
||||||
" so that expansion of commandline works
|
" so that expansion of commandline works
|
||||||
call test_override("char_avail", 1)
|
call test_override("char_avail", 1)
|
||||||
@@ -369,9 +367,8 @@ func Incsearch_cleanup()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline3()
|
func Test_search_cmdline3()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
call Cmdline3_prep()
|
call Cmdline3_prep()
|
||||||
1
|
1
|
||||||
" first match
|
" first match
|
||||||
@@ -382,9 +379,8 @@ func Test_search_cmdline3()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline3s()
|
func Test_search_cmdline3s()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
call Cmdline3_prep()
|
call Cmdline3_prep()
|
||||||
1
|
1
|
||||||
call feedkeys(":%s/the\<c-l>/xxx\<cr>", 'tx')
|
call feedkeys(":%s/the\<c-l>/xxx\<cr>", 'tx')
|
||||||
@@ -408,9 +404,8 @@ func Test_search_cmdline3s()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline3g()
|
func Test_search_cmdline3g()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
call Cmdline3_prep()
|
call Cmdline3_prep()
|
||||||
1
|
1
|
||||||
call feedkeys(":g/the\<c-l>/d\<cr>", 'tx')
|
call feedkeys(":g/the\<c-l>/d\<cr>", 'tx')
|
||||||
@@ -431,9 +426,8 @@ func Test_search_cmdline3g()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline3v()
|
func Test_search_cmdline3v()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
call Cmdline3_prep()
|
call Cmdline3_prep()
|
||||||
1
|
1
|
||||||
call feedkeys(":v/the\<c-l>/d\<cr>", 'tx')
|
call feedkeys(":v/the\<c-l>/d\<cr>", 'tx')
|
||||||
@@ -450,9 +444,8 @@ endfunc
|
|||||||
" See test/functional/legacy/search_spec.lua
|
" See test/functional/legacy/search_spec.lua
|
||||||
func Test_search_cmdline4()
|
func Test_search_cmdline4()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
" need to disable char_avail,
|
" need to disable char_avail,
|
||||||
" so that expansion of commandline works
|
" so that expansion of commandline works
|
||||||
call test_override("char_avail", 1)
|
call test_override("char_avail", 1)
|
||||||
@@ -484,9 +477,8 @@ func Test_search_cmdline4()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline5()
|
func Test_search_cmdline5()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
" Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
|
" Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
|
||||||
" regardless char_avail.
|
" regardless char_avail.
|
||||||
new
|
new
|
||||||
@@ -503,6 +495,46 @@ func Test_search_cmdline5()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
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()
|
func Test_search_cmdline7()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
" Test that pressing <c-g> in an empty command line
|
" Test that pressing <c-g> in an empty command line
|
||||||
@@ -598,26 +630,226 @@ func Test_search_regexp()
|
|||||||
enew!
|
enew!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for search('multi-byte char', 'bce')
|
func Test_search_cmdline_incsearch_highlight()
|
||||||
func Test_search_multibyte()
|
CheckFunction test_override
|
||||||
let save_enc = &encoding
|
CheckOption incsearch
|
||||||
set encoding=utf8
|
|
||||||
enew!
|
set incsearch hlsearch
|
||||||
call append('$', 'A')
|
" need to disable char_avail,
|
||||||
call cursor(2, 1)
|
" so that expansion of commandline works
|
||||||
call assert_equal(2, search('A', 'bce', line('.')))
|
call test_override("char_avail", 1)
|
||||||
enew!
|
new
|
||||||
let &encoding = save_enc
|
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
|
||||||
|
|
||||||
|
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
|
endfunc
|
||||||
|
|
||||||
" Similar to Test_incsearch_substitute() but with a screendump halfway.
|
" Similar to Test_incsearch_substitute() but with a screendump halfway.
|
||||||
func Test_incsearch_substitute_dump()
|
func Test_incsearch_substitute_dump()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
CheckScreendump
|
||||||
endif
|
|
||||||
if !CanRunVimInTerminal()
|
|
||||||
throw 'Skipped: cannot make screendumps'
|
|
||||||
endif
|
|
||||||
call writefile([
|
call writefile([
|
||||||
\ 'set incsearch hlsearch scrolloff=0',
|
\ 'set incsearch hlsearch scrolloff=0',
|
||||||
\ 'for n in range(1, 10)',
|
\ 'for n in range(1, 10)',
|
||||||
@@ -724,12 +956,8 @@ func Test_incsearch_substitute_dump()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_incsearch_highlighting()
|
func Test_incsearch_highlighting()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
CheckScreendump
|
||||||
endif
|
|
||||||
if !CanRunVimInTerminal()
|
|
||||||
throw 'Skipped: cannot make screendumps'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call writefile([
|
call writefile([
|
||||||
\ 'set incsearch hlsearch',
|
\ 'set incsearch hlsearch',
|
||||||
@@ -745,16 +973,40 @@ func Test_incsearch_highlighting()
|
|||||||
call term_sendkeys(buf, ":%s;ello/the")
|
call term_sendkeys(buf, ":%s;ello/the")
|
||||||
call VerifyScreenDump(buf, 'Test_incsearch_substitute_15', {})
|
call VerifyScreenDump(buf, 'Test_incsearch_substitute_15', {})
|
||||||
call term_sendkeys(buf, "<Esc>")
|
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
|
endfunc
|
||||||
|
|
||||||
" Similar to Test_incsearch_substitute_dump() for :sort
|
" Similar to Test_incsearch_substitute_dump() for :sort
|
||||||
func Test_incsearch_sort_dump()
|
func Test_incsearch_sort_dump()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
CheckScreendump
|
||||||
endif
|
|
||||||
if !CanRunVimInTerminal()
|
|
||||||
throw 'Skipped: cannot make screendumps'
|
|
||||||
endif
|
|
||||||
call writefile([
|
call writefile([
|
||||||
\ 'set incsearch hlsearch scrolloff=0',
|
\ 'set incsearch hlsearch scrolloff=0',
|
||||||
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
|
\ '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
|
" Similar to Test_incsearch_substitute_dump() for :vimgrep famiry
|
||||||
func Test_incsearch_vimgrep_dump()
|
func Test_incsearch_vimgrep_dump()
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
CheckScreendump
|
||||||
endif
|
|
||||||
if !CanRunVimInTerminal()
|
|
||||||
throw 'Skipped: cannot make screendumps'
|
|
||||||
endif
|
|
||||||
call writefile([
|
call writefile([
|
||||||
\ 'set incsearch hlsearch scrolloff=0',
|
\ 'set incsearch hlsearch scrolloff=0',
|
||||||
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
|
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
|
||||||
@@ -820,9 +1069,8 @@ endfunc
|
|||||||
|
|
||||||
func Test_keep_last_search_pattern()
|
func Test_keep_last_search_pattern()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
new
|
new
|
||||||
call setline(1, ['foo', 'foo', 'foo'])
|
call setline(1, ['foo', 'foo', 'foo'])
|
||||||
set incsearch
|
set incsearch
|
||||||
@@ -842,9 +1090,8 @@ endfunc
|
|||||||
|
|
||||||
func Test_word_under_cursor_after_match()
|
func Test_word_under_cursor_after_match()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
new
|
new
|
||||||
call setline(1, 'foo bar')
|
call setline(1, 'foo bar')
|
||||||
set incsearch
|
set incsearch
|
||||||
@@ -862,9 +1109,8 @@ endfunc
|
|||||||
|
|
||||||
func Test_subst_word_under_cursor()
|
func Test_subst_word_under_cursor()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
new
|
new
|
||||||
call setline(1, ['int SomeLongName;', 'for (xxx = 1; xxx < len; ++xxx)'])
|
call setline(1, ['int SomeLongName;', 'for (xxx = 1; xxx < len; ++xxx)'])
|
||||||
set incsearch
|
set incsearch
|
||||||
@@ -878,130 +1124,6 @@ func Test_subst_word_under_cursor()
|
|||||||
set noincsearch
|
set noincsearch
|
||||||
endfunc
|
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()
|
func Test_incsearch_substitute_long_line()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
new
|
new
|
||||||
@@ -1018,9 +1140,8 @@ func Test_incsearch_substitute_long_line()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_undefined_behaviour()
|
func Test_search_undefined_behaviour()
|
||||||
if !has("terminal")
|
CheckFeature terminal
|
||||||
return
|
|
||||||
endif
|
|
||||||
let h = winheight(0)
|
let h = winheight(0)
|
||||||
if h < 3
|
if h < 3
|
||||||
return
|
return
|
||||||
@@ -1036,6 +1157,18 @@ func Test_search_undefined_behaviour2()
|
|||||||
call search("\%UC0000000")
|
call search("\%UC0000000")
|
||||||
endfunc
|
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?
|
" This was causing E874. Also causes an invalid read?
|
||||||
func Test_look_behind()
|
func Test_look_behind()
|
||||||
new
|
new
|
||||||
@@ -1074,9 +1207,8 @@ func Test_search_Ctrl_L_combining()
|
|||||||
" ' ̇' U+0307 Dec:775 COMBINING DOT ABOVE ̇ /\%u307\Z "\u0307"
|
" ' ̇' U+0307 Dec:775 COMBINING DOT ABOVE ̇ /\%u307\Z "\u0307"
|
||||||
" ' ̣' U+0323 Dec:803 COMBINING DOT BELOW ̣ /\%u323 "\u0323"
|
" ' ̣' U+0323 Dec:803 COMBINING DOT BELOW ̣ /\%u323 "\u0323"
|
||||||
" Those should also appear on the commandline
|
" Those should also appear on the commandline
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
call Cmdline3_prep()
|
call Cmdline3_prep()
|
||||||
1
|
1
|
||||||
let bufcontent = ['', 'Miạ̀́̇m']
|
let bufcontent = ['', 'Miạ̀́̇m']
|
||||||
@@ -1126,9 +1258,8 @@ endfunc
|
|||||||
|
|
||||||
func Test_incsearch_add_char_under_cursor()
|
func Test_incsearch_add_char_under_cursor()
|
||||||
CheckFunction test_override
|
CheckFunction test_override
|
||||||
if !exists('+incsearch')
|
CheckOption incsearch
|
||||||
return
|
|
||||||
endif
|
|
||||||
set incsearch
|
set incsearch
|
||||||
new
|
new
|
||||||
call setline(1, ['find match', 'anything'])
|
call setline(1, ['find match', 'anything'])
|
||||||
|
Reference in New Issue
Block a user