robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1" Tests for search_stats, when "S" is not in 'shortmess' 2 3source check.vim 4source screendump.vim 5 6func Test_search_stat () 7new 8set shortmess -= S 9" Append 50 lines with text to search for, "foobar" appears 20 times 10call append ( 0 , repeat ([ 'foobar' , 'foo' , 'fooooobar' , 'foba' , 'foobar' ], 10 )) 11 12call cursor ( 1 , 1 ) 13 14" searchcount() returns an empty dictionary when previous pattern was not set 15call assert_equal ({}, searchcount (#{ pattern : '' })) 16" but setting @/ should also work (even 'n' nor 'N' was executed) 17" recompute the count when the last position is different. 18call assert_equal ( 19 \#{ current : 1 , exact_match : 1 , total : 40 , incomplete : 0 , maxcount : 99 }, 20 \searchcount (#{ pattern : 'foo' })) 21call assert_equal ( 22 \#{ current : 0 , exact_match : 0 , total : 10 , incomplete : 0 , maxcount : 99 }, 23 \searchcount (#{ pattern : 'fooooobar' })) 24call assert_equal ( 25 \#{ current : 0 , exact_match : 0 , total : 10 , incomplete : 0 , maxcount : 99 }, 26 \searchcount (#{ pattern : 'fooooobar' , pos : [ 2 , 1 , 0 ]})) 27call assert_equal ( 28 \#{ current : 1 , exact_match : 1 , total : 10 , incomplete : 0 , maxcount : 99 }, 29 \searchcount (#{ pattern : 'fooooobar' , pos : [ 3 , 1 , 0 ]})) 30" on last char of match 31call assert_equal ( 32 \#{ current : 1 , exact_match : 1 , total : 10 , incomplete : 0 , maxcount : 99 }, 33 \searchcount (#{ pattern : 'fooooobar' , pos : [ 3 , 9 , 0 ]})) 34" on char after match 35call assert_equal ( 36 \#{ current : 1 , exact_match : 0 , total : 10 , incomplete : 0 , maxcount : 99 }, 37 \searchcount (#{ pattern : 'fooooobar' , pos : [ 3 , 10 , 0 ]})) 38call assert_equal ( 39 \#{ current : 1 , exact_match : 0 , total : 10 , incomplete : 0 , maxcount : 99 }, 40 \searchcount (#{ pattern : 'fooooobar' , pos : [ 4 , 1 , 0 ]})) 41call assert_equal ( 42 \#{ current : 1 , exact_match : 0 , total : 2 , incomplete : 2 , maxcount : 1 }, 43 \searchcount (#{ pattern : 'fooooobar' , pos : [ 4 , 1 , 0 ], maxcount : 1 })) 44call assert_equal ( 45 \#{ current : 0 , exact_match : 0 , total : 2 , incomplete : 2 , maxcount : 1 }, 46 \searchcount (#{ pattern : 'fooooobar' , maxcount : 1 })) 47 48" match at second line 49let messages_before = execute ( 'messages' ) 50let @/= 'fo*\(bar\?\)\?' 51let g: a = execute ( ':unsilent :norm! n' ) 52let stat = '\[2/50\]' 53let pat = escape ( @/, '()*?' ) . '\s\+' 54call assert_match ( pat .. stat , g: a ) 55call assert_equal ( 56 \#{ current : 2 , exact_match : 1 , total : 50 , incomplete : 0 , maxcount : 99 }, 57 \searchcount (#{ recompute : 0 })) 58" didn't get added to message history 59call assert_equal ( messages_before , execute ( 'messages' )) 60 61" Match at last line 62call cursor ( line ( '$' ) - 2 , 1 ) 63let g: a = execute ( ':unsilent :norm! n' ) 64let stat = '\[50/50\]' 65call assert_match ( pat .. stat , g: a ) 66call assert_equal ( 67 \#{ current : 50 , exact_match : 1 , total : 50 , incomplete : 0 , maxcount : 99 }, 68 \searchcount (#{ recompute : 0 })) 69 70" No search stat 71set shortmess += S 72call cursor ( 1 , 1 ) 73let stat = '\[2/50\]' 74let g: a = execute ( ':unsilent :norm! n' ) 75call assert_notmatch ( pat .. stat , g: a ) 76" n does not update search stat 77call assert_equal ( 78 \#{ current : 50 , exact_match : 1 , total : 50 , incomplete : 0 , maxcount : 99 }, 79 \searchcount (#{ recompute : 0 })) 80call assert_equal ( 81 \#{ current : 2 , exact_match : 1 , total : 50 , incomplete : 0 , maxcount : 99 }, 82 \searchcount (#{ recompute : v: true })) 83set shortmess -= S 84 85" Many matches 86call cursor ( line ( '$' ) - 2 , 1 ) 87let @/= '.' 88let pat = escape ( @/, '()*?' ) . '\s\+' 89let g: a = execute ( ':unsilent :norm! n' ) 90let stat = '\[>99/>99\]' 91call assert_match ( pat .. stat , g: a ) 92call assert_equal ( 93 \#{ current : 100 , exact_match : 0 , total : 100 , incomplete : 2 , maxcount : 99 }, 94 \searchcount (#{ recompute : 0 })) 95call assert_equal ( 96 \#{ current : 272 , exact_match : 1 , total : 280 , incomplete : 0 , maxcount : 0 }, 97 \searchcount (#{ recompute : v: true , maxcount : 0 , timeout : 200 })) 98call assert_equal ( 99 \#{ current : 1 , exact_match : 1 , total : 280 , incomplete : 0 , maxcount : 0 }, 100 \searchcount (#{ recompute : 1 , maxcount : 0 , pos : [ 1 , 1 , 0 ], timeout : 200 })) 101call cursor ( line ( '$' ), 1 ) 102let g: a = execute ( ':unsilent :norm! n' ) 103let stat = 'W \[1/>99\]' 104call assert_match ( pat .. stat , g: a ) 105call assert_equal ( 106 \#{ current : 1 , exact_match : 1 , total : 100 , incomplete : 2 , maxcount : 99 }, 107 \searchcount (#{ recompute : 0 })) 108call assert_equal ( 109 \#{ current : 1 , exact_match : 1 , total : 280 , incomplete : 0 , maxcount : 0 }, 110 \searchcount (#{ recompute : 1 , maxcount : 0 , timeout : 200 })) 111call assert_equal ( 112 \#{ current : 271 , exact_match : 1 , total : 280 , incomplete : 0 , maxcount : 0 }, 113 \searchcount (#{ recompute : 1 , maxcount : 0 , pos : [ line ( '$' ) - 2 , 1 , 0 ], timeout : 200 })) 114 115" Many matches 116call cursor ( 1 , 1 ) 117let g: a = execute ( ':unsilent :norm! n' ) 118let stat = '\[2/>99\]' 119call assert_match ( pat .. stat , g: a ) 120call cursor ( 1 , 1 ) 121let g: a = execute ( ':unsilent :norm! N' ) 122let stat = 'W \[>99/>99\]' 123call assert_match ( pat .. stat , g: a ) 124 125" right-left 126if exists ( "+rightleft" ) 127set rl 128call cursor ( 1 , 1 ) 129let @/= 'foobar' 130let pat = 'raboof/\s\+' 131let g: a = execute ( ':unsilent :norm! n' ) 132let stat = '\[20/2\]' 133call assert_match ( pat .. stat , g: a ) 134set norl 135endif 136 137" right-left bottom 138if exists ( "+rightleft" ) 139set rl 140call cursor ( '$' , 1 ) 141let pat = 'raboof?\s\+' 142let g: a = execute ( ':unsilent :norm! N' ) 143let stat = '\[20/20\]' 144call assert_match ( pat .. stat , g: a ) 145set norl 146endif 147 148" right-left back at top 149if exists ( "+rightleft" ) 150set rl 151call cursor ( '$' , 1 ) 152let pat = 'raboof/\s\+' 153let g: a = execute ( ':unsilent :norm! n' ) 154let stat = 'W \[20/1\]' 155call assert_match ( pat .. stat , g: a ) 156set norl 157endif 158 159" normal, back at bottom 160call cursor ( 1 , 1 ) 161let @/= 'foobar' 162let pat = '?foobar\s\+' 163let g: a = execute ( ':unsilent :norm! N' ) 164let stat = 'W \[20/20\]' 165call assert_match ( pat .. stat , g: a ) 166call assert_match ( 'W \[20/20\]' , Screenline ( & lines )) 167 168" normal, no match 169call cursor ( 1 , 1 ) 170let @/= 'zzzzzz' 171let g: a = '' 172try 173let g: a = execute ( ':unsilent :norm! n' ) 174catch /^Vim\%((\a\+)\)\=:E486/ 175let stat = '' 176" error message is not redir'ed to g:a, it is empty 177call assert_true ( empty ( g: a )) 178catch 179call assert_false ( 1 ) 180endtry 181 182" with count 183call cursor ( 1 , 1 ) 184let @/= 'fo*\(bar\?\)\?' 185let g: a = execute ( ':unsilent :norm! 2n' ) 186let stat = '\[3/50\]' 187let pat = escape ( @/, '()*?' ) . '\s\+' 188call assert_match ( pat .. stat , g: a ) 189let g: a = execute ( ':unsilent :norm! 2n' ) 190let stat = '\[5/50\]' 191call assert_match ( pat .. stat , g: a ) 192 193" with offset 194call cursor ( 1 , 1 ) 195call feedkeys ( "/fo*\\(bar\\?\\)\\?/+1\<cr>" , 'tx' ) 196let g: a = execute ( ':unsilent :norm! n' ) 197let stat = '\[5/50\]' 198let pat = escape ( @/.. '/+1' , '()*?' ) . '\s\+' 199call assert_match ( pat .. stat , g: a ) 200 201" with semicolon, with/without trailing slash 202call cursor ( 1 , 1 ) 203call feedkeys ( "/fooo/;/foobar/\<cr>" , 'tx' ) 204call assert_match ( '^/foobar\s*\[2/20\]' , Screenline ( & lines )) 205call feedkeys ( "/fooo/;/foobar\<cr>" , 'tx' ) 206call assert_match ( '^/foobar\s*\[4/20\]' , Screenline ( & lines )) 207 208" normal, n comes from a mapping 209" Need to move over more than 64 lines to trigger char_avail(. 210nnoremap n nzv 211call cursor ( 1 , 1 ) 212call append ( 50 , repeat ([ 'foobar' , 'foo' , 'fooooobar' , 'foba' , 'foobar' ], 10 )) 213call setline ( 2 , 'find this' ) 214call setline ( 70 , 'find this' ) 215let @/= 'find this' 216let pat = '/find this\s\+' 217let g: a = execute ( ':unsilent :norm n' ) 218" g:a will contain several lines 219let g: b = split ( g: a , "\n" )[ -1 ] 220let stat = '\[1/2\]' 221call assert_match ( pat .. stat , g: b ) 222unmap n 223 224" normal, but silent 225call cursor ( 1 , 1 ) 226let @/= 'find this' 227let pat = '/find this\s\+' 228let g: a = execute ( ':norm! n' ) 229let stat = '\[1/2\]' 230call assert_notmatch ( pat .. stat , g: a ) 231 232" normal, n comes from a silent mapping 233" First test a normal mapping, then a silent mapping 234call cursor ( 1 , 1 ) 235nnoremap n n 236let @/= 'find this' 237let pat = '/find this\s\+' 238let g: a = execute ( ':unsilent :norm n' ) 239let g: b = split ( g: a , "\n" )[ -1 ] 240let stat = '\[1/2\]' 241call assert_match ( pat .. stat , g: b ) 242nnoremap <silent> n n 243call cursor ( 1 , 1 ) 244let g: a = execute ( ':unsilent :norm n' ) 245let g: b = split ( g: a , "\n" )[ -1 ] 246let stat = '\[1/2\]' 247call assert_notmatch ( pat .. stat , g: b ) 248call assert_match ( stat , g: b ) 249" Test that the message is not truncated 250" it would insert '...' into the output. 251call assert_match ( '^\s\+' .. stat , g: b ) 252unmap n 253 254" Time out 255 %delete _ 256call append ( 0 , repeat ([ 'foobar' , 'foo' , 'fooooobar' , 'foba' , 'foobar' ], 100000 )) 257call cursor ( 1 , 1 ) 258call assert_equal ( 1 , searchcount (#{ pattern : 'foo' , maxcount : 0 , timeout : 1 }). incomplete ) 259 260" Clean up 261set shortmess += S 262" close the window 263bwipe ! 264endfunc 265 266func Test_searchcount_fails () 267call assert_fails ( 'echo searchcount("boo!")' , 'E1206:' ) 268call assert_fails ( 'echo searchcount({"timeout" : []})' , 'E745:' ) 269call assert_fails ( 'echo searchcount({"maxcount" : []})' , 'E745:' ) 270call assert_fails ( 'echo searchcount({"pattern" : []})' , 'E730:' ) 271call assert_fails ( 'echo searchcount({"pos" : 1})' , 'E475:' ) 272call assert_fails ( 'echo searchcount({"pos" : [1]})' , 'E475:' ) 273call assert_fails ( 'echo searchcount({"pos" : [[], 2, 3]})' , 'E745:' ) 274call assert_fails ( 'echo searchcount({"pos" : [1, [], 3]})' , 'E745:' ) 275call assert_fails ( 'echo searchcount({"pos" : [1, 2, []]})' , 'E745:' ) 276endfunc 277 278func Test_search_stat_narrow_screen () 279" This used to crash Vim 280let save_columns = & columns 281try 282let after =<< trim [CODE] 283set laststatus=2 284set columns=16 285set shortmess-=S showcmd 286call setline(1, 'abc') 287call feedkeys("/abc\<CR>:quit!\<CR>") 288autocmd VimLeavePre * call writefile(["done"], "Xdone") 289[CODE] 290 291if ! RunVim ([], after , '--clean' ) 292return 293endif 294call assert_equal ( "done" , readfile ( "Xdone" )[ 0 ]) 295call delete ( 'Xdone' ) 296finally 297let & columns = save_columns 298endtry 299endfunc 300 301func Test_searchcount_in_statusline () 302CheckScreendump 303 304let lines =<< trim END 305set shortmess-=S 306call append(0, 'this is something') 307function TestSearchCount() abort 308let search_count = searchcount() 309if !empty(search_count) 310return '[' . search_count.current . '/' . search_count.total . ']' 311else 312return '' 313endif 314endfunction 315set hlsearch 316set laststatus=2 statusline+=%{TestSearchCount()} 317END 318call writefile ( lines , 'Xsearchstatusline' , 'D' ) 319let buf = RunVimInTerminal ( '-S Xsearchstatusline' , #{ rows : 10 }) 320call TermWait ( buf ) 321call term_sendkeys ( buf , "/something" ) 322call VerifyScreenDump ( buf , 'Test_searchstat_4' , {}) 323 324call term_sendkeys ( buf , "\<Esc>" ) 325call StopVimInTerminal ( buf ) 326endfunc 327 328func Test_search_stat_foldopen () 329CheckScreendump 330 331let lines =<< trim END 332set shortmess-=S 333setl foldenable foldmethod=indent foldopen-=search 334call append(0, ['if', "\tfoo", "\tfoo", 'endif']) 335let @/ = 'foo' 336call cursor(1,1) 337norm n 338END 339call writefile ( lines , 'Xsearchstat1' , 'D' ) 340 341let buf = RunVimInTerminal ( '-S Xsearchstat1' , #{ rows : 10 }) 342call VerifyScreenDump ( buf , 'Test_searchfoldopen_1' , {}) 343 344call term_sendkeys ( buf , "n" ) 345call VerifyScreenDump ( buf , 'Test_searchfoldopen_2' , {}) 346 347call term_sendkeys ( buf , "n" ) 348call VerifyScreenDump ( buf , 'Test_searchfoldopen_2' , {}) 349 350call StopVimInTerminal ( buf ) 351endfunc 352 353func ! Test_search_stat_screendump () 354CheckScreendump 355 356let lines =<< trim END 357set shortmess-=S 358" Append 50 lines with text to search for, "foobar" appears 20 times 359call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20)) 360call setline(2, 'find this') 361call setline(70, 'find this') 362nnoremap n n 363let @/ = 'find this' 364call cursor(1,1) 365norm n 366END 367call writefile ( lines , 'Xsearchstat' , 'D' ) 368let buf = RunVimInTerminal ( '-S Xsearchstat' , #{ rows : 10 }) 369call VerifyScreenDump ( buf , 'Test_searchstat_1' , {}) 370 371call term_sendkeys ( buf , ":nnoremap <silent> n n\<cr>" ) 372call term_sendkeys ( buf , "gg0n" ) 373call VerifyScreenDump ( buf , 'Test_searchstat_2' , {}) 374 375call StopVimInTerminal ( buf ) 376endfunc 377 378func Test_search_stat_then_gd () 379CheckScreendump 380 381let lines =<< trim END 382call setline(1, ['int cat;', 'int dog;', 'cat = dog;']) 383set shortmess-=S 384set hlsearch 385END 386call writefile ( lines , 'Xsearchstatgd' , 'D' ) 387 388let buf = RunVimInTerminal ( '-S Xsearchstatgd' , #{ rows : 10 }) 389call term_sendkeys ( buf , "/dog\<CR>" ) 390call VerifyScreenDump ( buf , 'Test_searchstatgd_1' , {}) 391 392call term_sendkeys ( buf , "G0gD" ) 393call VerifyScreenDump ( buf , 'Test_searchstatgd_2' , {}) 394 395call StopVimInTerminal ( buf ) 396endfunc 397 398func Test_search_stat_and_incsearch () 399CheckScreendump 400 401let lines =<< trim END 402call setline(1, ['abc--c', '--------abc', '--abc']) 403set hlsearch 404set incsearch 405set bg=dark 406set showtabline=2 407 408function MyTabLine() 409try 410let a=searchcount(#{recompute: 1, maxcount: -1}) 411return a.current .. '/' .. a.total 412catch 413return '' 414endtry 415endfunction 416 417set tabline=%!MyTabLine() 418END 419call writefile ( lines , 'Xsearchstat_inc' , 'D' ) 420 421let buf = RunVimInTerminal ( '-S Xsearchstat_inc' , #{ rows : 10 }) 422call TermWait ( buf , 100 ) 423call term_sendkeys ( buf , "/abc" ) 424call TermWait ( buf ) 425" The first 3 chars on line 2 should have highlighting, but the following not 426" So assert the attr value of those 4 chars 427call WaitForAssert ({ ->assert_true ( 428 \term_scrape ( buf , 2 )[ 0 ]. attr == term_scrape ( buf , 2 )[ 1 ]. attr && 429 \term_scrape ( buf , 2 )[ 1 ]. attr == term_scrape ( buf , 2 )[ 2 ]. attr && 430 \term_scrape ( buf , 2 )[ 2 ]. attr != term_scrape ( buf , 2 )[ 3 ]. attr )}, 1000 ) 431call VerifyScreenDump ( buf , 'Test_searchstat_inc_1' , {}) 432 433call term_sendkeys ( buf , "\<c-g>" ) 434call WaitForAssert ({ ->assert_match ( '^3' , term_getline ( buf , 1 ))}, 1000 ) 435call VerifyScreenDump ( buf , 'Test_searchstat_inc_2' , {}) 436 437call term_sendkeys ( buf , "\<c-g>" ) 438call WaitForAssert ({ ->assert_match ( '^1' , term_getline ( buf , 1 ))}, 1000 ) 439call VerifyScreenDump ( buf , 'Test_searchstat_inc_3' , {}) 440 441call term_sendkeys ( buf , "\<esc>:qa\<cr>" ) 442call TermWait ( buf ) 443 444call StopVimInTerminal ( buf ) 445endfunc 446 447func Test_search_stat_backwards () 448CheckScreendump 449 450let lines =<< trim END 451set shm-=S 452call setline(1, ['test', '']) 453END 454call writefile ( lines , 'Xsearchstat_back' , 'D' ) 455 456let buf = RunVimInTerminal ( '-S Xsearchstat_back' , #{ rows : 10 }) 457call term_sendkeys ( buf , "*" ) 458call TermWait ( buf ) 459call VerifyScreenDump ( buf , 'Test_searchstat_back_1' , {}) 460 461call term_sendkeys ( buf , "N" ) 462call TermWait ( buf ) 463call VerifyScreenDump ( buf , 'Test_searchstat_back_2' , {}) 464 465call term_sendkeys ( buf , ":set shm+=S\<cr>N" ) 466call TermWait ( buf ) 467" shows "Search Hit Bottom.." 468call VerifyScreenDump ( buf , 'Test_searchstat_back_3' , {}) 469 470call term_sendkeys ( buf , "\<esc>:qa\<cr>" ) 471call TermWait ( buf ) 472 473call StopVimInTerminal ( buf ) 474endfunc 475 476func Test_search_stat_smartcase_ignorecase () 477CheckRunVimInTerminal 478 479let lines =<< trim END 480set shm-=S ignorecase smartcase 481call setline(1, [' MainmainmainmmmainmAin', '']) 482END 483call writefile ( lines , 'Xsearchstat_ignorecase' , '5' ) 484 485let buf = RunVimInTerminal ( '-S Xsearchstat_ignorecase' , #{ rows : 10 }) 486call term_sendkeys ( buf , "/main\<cr>nnnn" ) 487call WaitForAssert ({ ->assert_match ( '\[5\/5\]' , term_getline ( buf , 10 ))}, 1000 ) 488 489call term_sendkeys ( buf , "/mAin\<cr>" ) 490call WaitForAssert ({ ->assert_match ( '\[1\/1\]' , term_getline ( buf , 10 ))}, 1000 ) 491 492call StopVimInTerminal ( buf ) 493endfunc 494 495func Test_search_stat_option_values () 496call assert_fails ( ':set maxsearchcount=0' , 'E487:' ) 497call assert_fails ( ':set maxsearchcount=10000' , 'E474:' ) 498set maxsearchcount = 9999 499call assert_equal ( 9999 , & msc ) 500set maxsearchcount = 1 501call assert_equal ( 1 , & msc ) 502set maxsearchcount = 999 503call assert_equal ( 999 , & msc ) 504set maxsearchcount & vim 505endfunc 506 507func Test_search_stat_option () 508" Asan causes wrong results, because the search times out 509CheckNotAsan 510" s390x is too slow, search times out 511CheckNotS390 512" Mark the test as flaky as the search may still occasionally time out 513let g: test_is_flaky = 1 514 515enew 516set shortmess -= S 517set maxsearchcount = 999 518" Append 1000 lines with text to search for, "foobar" appears 20 times 519call append ( 0 , repeat ([ 'foobar' , 'foo' , 'fooooobar' , 'foba' , 'foobar' ], 1000 )) 520 521call cursor ( 1 , 1 ) 522call assert_equal ( 523 \#{ exact_match : 1 , current : 1 , incomplete : 2 , maxcount : 999 , total : 1000 }, 524 \searchcount (#{ pattern : 'fooooobar' , pos : [ 3 , 1 , 0 ]})) 525" on last char of match 526call assert_equal ( 527 \#{ exact_match : 1 , current : 1 , incomplete : 2 , maxcount : 999 , total : 1000 }, 528 \searchcount (#{ pattern : 'fooooobar' , pos : [ 3 , 9 , 0 ]})) 529" on char after match 530call assert_equal ( 531 \#{ exact_match : 0 , current : 1 , incomplete : 2 , maxcount : 999 , total : 1000 }, 532 \searchcount (#{ pattern : 'fooooobar' , pos : [ 3 , 10 , 0 ]})) 533 534" match at second line 535let messages_before = execute ( 'messages' ) 536let @/= 'fo*\(bar\?\)\?' 537let g: a = execute ( ':unsilent :norm! n' ) 538let stat = '\[2/>999\]' 539let pat = escape ( @/, '()*?' ) . '\s\+' 540call assert_match ( pat .. stat , g: a ) 541call assert_equal ( 542 \#{ exact_match : 1 , current : 2 , incomplete : 2 , maxcount : 999 , total : 1000 }, 543 \searchcount (#{ recompute : 0 })) 544" didn't get added to message history 545call assert_equal ( messages_before , execute ( 'messages' )) 546 547" If the test is being retried due to flakiness, extend the searchcount() 548" timeout, too 549let timeout = 500 * get ( g:, 'run_nr' , 1 ) 550 551" Many matches 552call cursor ( line ( '$' ) - 2 , 1 ) 553let @/= '.' 554let pat = escape ( @/, '()*?' ) . '\s\+' 555let g: a = execute ( ':unsilent :norm! n' ) 556let stat = '\[>999/>999\]' 557call assert_match ( pat .. stat , g: a ) 558call assert_equal ( 559 \#{ exact_match : 0 , current : 1000 , incomplete : 2 , maxcount : 999 , total : 1000 }, 560 \searchcount (#{ recompute : 0 })) 561call assert_equal ( 562 \#{ exact_match : 1 , current : 27992 , incomplete : 0 , maxcount : 0 , total : 28000 }, 563 \searchcount (#{ recompute : v: true , maxcount : 0 , timeout : timeout })) 564call assert_equal ( 565 \#{ exact_match : 1 , current : 1 , incomplete : 0 , maxcount : 0 , total : 28000 }, 566 \searchcount (#{ recompute : 1 , maxcount : 0 , pos : [ 1 , 1 , 0 ], timeout : timeout })) 567call cursor ( line ( '$' ), 1 ) 568let g: a = execute ( ':unsilent :norm! n' ) 569let stat = 'W \[1/>999\]' 570call assert_match ( pat .. stat , g: a ) 571call assert_equal ( 572 \#{ current : 1 , exact_match : 1 , total : 1000 , incomplete : 2 , maxcount : 999 }, 573 \searchcount (#{ recompute : 0 })) 574call assert_equal ( 575 \#{ current : 1 , exact_match : 1 , total : 28000 , incomplete : 0 , maxcount : 0 }, 576 \searchcount (#{ recompute : 1 , maxcount : 0 , timeout : timeout })) 577call assert_equal ( 578 \#{ current : 27991 , exact_match : 1 , total : 28000 , incomplete : 0 , maxcount : 0 }, 579 \searchcount (#{ recompute : 1 , maxcount : 0 , pos : [ line ( '$' ) - 2 , 1 , 0 ], timeout : timeout })) 580 581" Many matches 582call cursor ( 1 , 1 ) 583let g: a = execute ( ':unsilent :norm! n' ) 584let stat = '\[2/>999\]' 585call assert_match ( pat .. stat , g: a ) 586call cursor ( 1 , 1 ) 587let g: a = execute ( ':unsilent :norm! N' ) 588let stat = '\[>999/>999\]' 589call assert_match ( pat .. stat , g: a ) 590set maxsearchcount = 500 591call cursor ( 1 , 1 ) 592let g: a = execute ( ':unsilent :norm! n' ) 593let stat = '\[2/>500\]' 594call assert_match ( pat .. stat , g: a ) 595call cursor ( 1 , 1 ) 596let g: a = execute ( ':unsilent :norm! N' ) 597let stat = '\[>500/>500\]' 598call assert_match ( pat .. stat , g: a ) 599set maxsearchcount = 20 600call cursor ( 1 , 1 ) 601let g: a = execute ( ':unsilent :norm! n' ) 602let stat = '\[2/>20\]' 603call assert_match ( pat .. stat , g: a ) 604call cursor ( 1 , 1 ) 605let g: a = execute ( ':unsilent :norm! N' ) 606let stat = '\[>20/>20\]' 607call assert_match ( pat .. stat , g: a ) 608set maxsearchcount = 999 609 610" right-left 611if exists ( "+rightleft" ) 612set rl 613call cursor ( 1 , 1 ) 614let @/= 'foobar' 615let pat = 'raboof/\s\+' 616let g: a = execute ( ':unsilent :norm! n' ) 617let stat = '\[>999/2\]' 618call assert_match ( pat .. stat , g: a ) 619 620" right-left bottom 621call cursor ( '$' , 1 ) 622let pat = 'raboof?\s\+' 623let g: a = execute ( ':unsilent :norm! N' ) 624let stat = '\[>999/>999\]' 625call assert_match ( pat .. stat , g: a ) 626 627" right-left back at top 628call cursor ( '$' , 1 ) 629let pat = 'raboof/\s\+' 630let g: a = execute ( ':unsilent :norm! n' ) 631let stat = 'W \[>999/1\]' 632call assert_match ( pat .. stat , g: a ) 633set norl 634endif 635 636" normal, back at bottom 637call cursor ( 1 , 1 ) 638let @/= 'foobar' 639let pat = '?foobar\s\+' 640let g: a = execute ( ':unsilent :norm! N' ) 641let stat = 'W \[>999/>999\]' 642call assert_match ( pat .. stat , g: a ) 643call assert_match ( 'W \[>999/>999\]' , Screenline ( & lines )) 644 645" normal, no match 646call cursor ( 1 , 1 ) 647let @/= 'zzzzzz' 648let g: a = '' 649try 650let g: a = execute ( ':unsilent :norm! n' ) 651catch /^Vim\%((\a\+)\)\=:E486/ 652let stat = '' 653" error message is not redir'ed to g:a, it is empty 654call assert_true ( empty ( g: a )) 655catch 656call assert_false ( 1 ) 657endtry 658 659" Clean up 660set shortmess += S 661set maxsearchcount & vim 662" close the window 663bwipe ! 664endfunc 665 666" vim: shiftwidth=2 sts=2 expandtab