comparison src/testdir/test_search.vim @ 14524:e36d6e01708c v8.1.0275

patch 8.1.0275: 'incsearch' with :s doesn't start at cursor line commit https://github.com/vim/vim/commit/976b847f43dd16eb6cd809d2dcab7dde6045e176 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 12 15:49:47 2018 +0200 patch 8.1.0275: 'incsearch' with :s doesn't start at cursor line Problem: 'incsearch' with :s doesn't start at cursor line. Solution: Set cursor before parsing address. (closes https://github.com/vim/vim/issues/3318) Also accept a match at the start of the first line.
author Christian Brabandt <cb@256bit.org>
date Sun, 12 Aug 2018 16:00:06 +0200
parents 97641c4f5687
children 66b9514b5a99
comparison
equal deleted inserted replaced
14523:f67a38a09c6d 14524:e36d6e01708c
349 new 349 new
350 call setline(1, [' 1', ' 2 the~e', ' 3 the theother']) 350 call setline(1, [' 1', ' 2 the~e', ' 3 the theother'])
351 set incsearch 351 set incsearch
352 endfunc 352 endfunc
353 353
354 func Cmdline3_cleanup() 354 func Incsearch_cleanup()
355 set noincsearch 355 set noincsearch
356 call test_override("char_avail", 0) 356 call test_override("char_avail", 0)
357 bw! 357 bw!
358 endfunc 358 endfunc
359 359
365 1 365 1
366 " first match 366 " first match
367 call feedkeys("/the\<c-l>\<cr>", 'tx') 367 call feedkeys("/the\<c-l>\<cr>", 'tx')
368 call assert_equal(' 2 the~e', getline('.')) 368 call assert_equal(' 2 the~e', getline('.'))
369 369
370 call Cmdline3_cleanup() 370 call Incsearch_cleanup()
371 endfunc 371 endfunc
372 372
373 func Test_search_cmdline3s() 373 func Test_search_cmdline3s()
374 if !exists('+incsearch') 374 if !exists('+incsearch')
375 return 375 return
383 call assert_equal(' 2 xxxe', getline('.')) 383 call assert_equal(' 2 xxxe', getline('.'))
384 undo 384 undo
385 call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx') 385 call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
386 call assert_equal(' 2 xxxe', getline('.')) 386 call assert_equal(' 2 xxxe', getline('.'))
387 387
388 call Cmdline3_cleanup() 388 call Incsearch_cleanup()
389 endfunc 389 endfunc
390 390
391 func Test_search_cmdline3g() 391 func Test_search_cmdline3g()
392 if !exists('+incsearch') 392 if !exists('+incsearch')
393 return 393 return
398 call assert_equal(' 3 the theother', getline(2)) 398 call assert_equal(' 3 the theother', getline(2))
399 undo 399 undo
400 call feedkeys(":global/the\<c-l>/d\<cr>", 'tx') 400 call feedkeys(":global/the\<c-l>/d\<cr>", 'tx')
401 call assert_equal(' 3 the theother', getline(2)) 401 call assert_equal(' 3 the theother', getline(2))
402 402
403 call Cmdline3_cleanup() 403 call Incsearch_cleanup()
404 endfunc 404 endfunc
405 405
406 func Test_search_cmdline3v() 406 func Test_search_cmdline3v()
407 if !exists('+incsearch') 407 if !exists('+incsearch')
408 return 408 return
415 undo 415 undo
416 call feedkeys(":vglobal/the\<c-l>/d\<cr>", 'tx') 416 call feedkeys(":vglobal/the\<c-l>/d\<cr>", 'tx')
417 call assert_equal(1, line('$')) 417 call assert_equal(1, line('$'))
418 call assert_equal(' 2 the~e', getline(1)) 418 call assert_equal(' 2 the~e', getline(1))
419 419
420 call Cmdline3_cleanup() 420 call Incsearch_cleanup()
421 endfunc 421 endfunc
422 422
423 func Test_search_cmdline4() 423 func Test_search_cmdline4()
424 if !exists('+incsearch') 424 if !exists('+incsearch')
425 return 425 return
795 call term_sendkeys(buf, "\<Esc>") 795 call term_sendkeys(buf, "\<Esc>")
796 call StopVimInTerminal(buf) 796 call StopVimInTerminal(buf)
797 call delete('Xscript') 797 call delete('Xscript')
798 endfunc 798 endfunc
799 799
800 func Test_incsearch_substitute()
801 if !exists('+incsearch')
802 return
803 endif
804 call test_override("char_avail", 1)
805 new
806 set incsearch
807 for n in range(1, 10)
808 call setline(n, 'foo ' . n)
809 endfor
810 4
811 call feedkeys(":.,.+2s/foo\<BS>o\<BS>o/xxx\<cr>", 'tx')
812 call assert_equal('foo 3', getline(3))
813 call assert_equal('xxx 4', getline(4))
814 call assert_equal('xxx 5', getline(5))
815 call assert_equal('xxx 6', getline(6))
816 call assert_equal('foo 7', getline(7))
817
818 call Incsearch_cleanup()
819 endfunc
820
800 func Test_search_undefined_behaviour() 821 func Test_search_undefined_behaviour()
801 if !has("terminal") 822 if !has("terminal")
802 return 823 return
803 endif 824 endif
804 let h = winheight(0) 825 let h = winheight(0)