robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local n =require ( 'test.functional.testnvim' )() 2local t =require ( 'test.testutil' ) 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local clear , feed , exec , command =n . clear , n . feed , n . exec , n . command 7 8describe ( 'search stat' , function () 9local screen 10before_each ( function () 11clear () 12screen =Screen . new ( 30 , 10 ) 13end ) 14 15-- oldtest: Test_search_stat_screendump() 16it ( 'right spacing with silent mapping vim-patch:8.1.1970' , function () 17exec ( [[ 18set shortmess-=S 19" Append 50 lines with text to search for, "foobar" appears 20 times 20call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20)) 21call setline(2, 'find this') 22call setline(70, 'find this') 23nnoremap n n 24let @/ = 'find this' 25call cursor(1,1) 26norm n 27]] ) 28screen : expect ( [[ 29foobar | 30{10:^find this} | 31fooooobar | 32foba | 33foobar |*2 34foo | 35fooooobar | 36foba | 37/find this [1/2] | 38]] ) 39command ( 'nnoremap <silent> n n' ) 40feed ( 'gg0n' ) 41screen : expect ( [[ 42foobar | 43{10:^find this} | 44fooooobar | 45foba | 46foobar |*2 47foo | 48fooooobar | 49foba | 50[1/2] | 51]] ) 52end ) 53 54-- oldtest: Test_search_stat_foldopen() 55it ( 'when only match is in fold vim-patch:8.2.0840' , function () 56exec ( [[ 57set shortmess-=S 58setl foldenable foldmethod=indent foldopen-=search 59call append(0, ['if', "\tfoo", "\tfoo", 'endif']) 60let @/ = 'foo' 61call cursor(1,1) 62norm n 63]] ) 64screen : expect ( [[ 65if | 66{13:^+-- 2 lines: foo·············}| 67endif | 68| 69{1:~ }|*5 70/foo [1/2] | 71]] ) 72feed ( 'n' ) 73screen : expect ( [[ 74if | 75{13:^+-- 2 lines: foo·············}| 76endif | 77| 78{1:~ }|*5 79/foo W [1/2] | 80]] ) 81feed ( 'n' ) 82-- Note: there is an intermediate state where the search stat disappears. 83screen : expect_unchanged ( true ) 84end ) 85 86-- oldtest: Test_search_stat_then_gd() 87it ( 'is cleared by gd and gD vim-patch:8.2.3583' , function () 88exec ( [[ 89call setline(1, ['int cat;', 'int dog;', 'cat = dog;']) 90set shortmess-=S 91set hlsearch 92]] ) 93feed ( '/dog<CR>' ) 94screen : expect ( [[ 95int cat; | 96int {10:^dog}; | 97cat = {10:dog}; | 98{1:~ }|*6 99/dog [1/2] | 100]] ) 101feed ( 'G0gD' ) 102screen : expect ( [[ 103int {10:^cat}; | 104int dog; | 105{10:cat} = dog; | 106{1:~ }|*6 107| 108]] ) 109end ) 110 111-- oldtest: Test_search_stat_and_incsearch() 112it ( 'is not broken by calling searchcount() in tabline vim-patch:8.2.4378' , function () 113exec ( [[ 114call setline(1, ['abc--c', '--------abc', '--abc']) 115set hlsearch 116set incsearch 117set showtabline=2 118 119function MyTabLine() 120try 121let a=searchcount(#{recompute: 1, maxcount: -1}) 122return a.current .. '/' .. a.total 123catch 124return '' 125endtry 126endfunction 127 128set tabline=%!MyTabLine() 129]] ) 130 131feed ( '/abc' ) 132screen : expect ( [[ 133{2: }| 134{10:abc}--c | 135--------{2:abc} | 136--{10:abc} | 137{1:~ }|*5 138/abc^ | 139]] ) 140 141feed ( '<C-G>' ) 142screen : expect ( [[ 143{2:3/3 }| 144{10:abc}--c | 145--------{10:abc} | 146--{2:abc} | 147{1:~ }|*5 148/abc^ | 149]] ) 150 151feed ( '<C-G>' ) 152screen : expect ( [[ 153{2:1/3 }| 154{2:abc}--c | 155--------{10:abc} | 156--{10:abc} | 157{1:~ }|*5 158/abc^ | 159]] ) 160end ) 161 162-- oldtest: Test_search_stat_backwards() 163it ( 'when searching backwards' , function () 164screen : try_resize ( 60 , 10 ) 165exec ( [[ 166set shm-=S 167call setline(1, ['test', '']) 168]] ) 169 170feed ( '*' ) 171screen : expect ( [[ 172{10:^test} | 173| 174{1:~ }|*7 175/\<test\> W [1/1] | 176]] ) 177 178feed ( 'N' ) 179screen : expect ( [[ 180{10:^test} | 181| 182{1:~ }|*7 183?\<test\> W [1/1] | 184]] ) 185 186command ( 'set shm+=S' ) 187feed ( 'N' ) 188-- shows "Search Hit Bottom.." 189screen : expect ( [[ 190{10:^test} | 191| 192{1:~ }|*7 193{19:search hit TOP, continuing at BOTTOM} | 194]] ) 195end ) 196 197-- oldtest: Test_search_stat_smartcase_ignorecase() 198it ( 'when changing case of pattern' , function () 199exec ( [[ 200set shm-=S ignorecase smartcase 201call setline(1, [' MainmainmainmmmainmAin', '']) 202]] ) 203 204feed ( '/main<cr>nnnn' ) 205screen : expect ( [[ 206{10:Mainmainmain}mm{10:main^mAin} | 207| 208{1:~ }|*7 209/main [5/5] | 210]] ) 211 212feed ( '/mAin<cr>' ) 213screen : expect ( [[ 214Mainmainmainmmmain{10:^mAin} | 215| 216{1:~ }|*7 217/mAin W [1/1] | 218]] ) 219end ) 220end )