robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
dab5fab948
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each , finally =t . describe , t . it , t . before_each , t . finally 6local clear =n . clear 7local exec =n . exec 8local feed =n . feed 9local api =n . api 10local eq =t . eq 11local fn =n . fn 12 13describe ( 'normal' , function () 14local screen 15 16before_each ( function () 17clear () 18screen =Screen . new ( 40 , 19 ) 19end ) 20 21-- oldtest: Test_normal_j_below_botline() 22it ( [[no skipped lines with "j" scrolling below botline and 'foldmethod' not "manual"]] , function () 23exec ( [[ 24set number foldmethod=diff scrolloff=0 25call setline(1, map(range(1, 9), 'repeat(v:val, 200)')) 26norm Lj 27]] ) 28screen : expect ( [[ 29{8: 2 }222222222222222222222222222222222222| 30{8: }222222222222222222222222222222222222|*4 31{8: }22222222222222222222 | 32{8: 3 }333333333333333333333333333333333333| 33{8: }333333333333333333333333333333333333|*4 34{8: }33333333333333333333 | 35{8: 4 }^444444444444444444444444444444444444| 36{8: }444444444444444444444444444444444444|*4 37{8: }44444444444444444444 | 38| 39]] ) 40end ) 41 42-- oldtest: Test_single_line_scroll() 43it ( '(Half)-page scroll up or down reveals virtual lines #19605, #27967' , function () 44fn . setline ( 1 , 'foobar one two three' ) 45exec ( 'set smoothscroll' ) 46local ns =api . nvim_create_namespace ( '' ) 47api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 48virt_lines ={ { { '---' , 'IncSearch' } } } , 49virt_lines_above =true , 50} ) 51-- Nvim: not actually necessary to scroll down to hide the virtual line. 52-- Check topfill instead of skipcol and show the screen state. 53feed ( '<C-E>' ) 54eq ( 0 , fn . winsaveview (). topfill ) 55local s1 =[[ 56^foobar one two three | 57{1:~ }|*17 58| 59]] 60screen : expect ( s1 ) 61feed ( '<C-B>' ) 62eq ( 1 , fn . winsaveview (). topfill ) 63local s2 =[[ 64{2:---} | 65^foobar one two three | 66{1:~ }|*16 67| 68]] 69screen : expect ( s2 ) 70feed ( '<C-E>' ) 71eq ( 0 , fn . winsaveview (). topfill ) 72screen : expect ( s1 ) 73feed ( '<C-U>' ) 74eq ( 1 , fn . winsaveview (). topfill ) 75screen : expect ( s2 ) 76 77-- Nvim: also test virt_lines below the last line 78feed ( 'yy100pG<C-L>' ) 79api . nvim_buf_set_extmark ( 0 , ns , 100 , 0 , { virt_lines ={ { { '---' , 'IncSearch' } } } } ) 80screen : expect ( { 81grid =[[ 82foobar one two three |*17 83^foobar one two three | 84| 85]] , 86} ) 87feed ( '<C-F>' ) 88screen : expect ( { 89grid =[[ 90^foobar one two three | 91{2:---} | 92{1:~ }|*16 93| 94]] , 95} ) 96feed ( 'ggG<C-D>' ) 97screen : expect ( { 98grid =[[ 99foobar one two three |*16 100^foobar one two three | 101{2:---} | 102| 103]] , 104} ) 105end ) 106 107-- oldtest: Test_normal_gm() 108it ( 'gm sets curswant correctly' , function () 109screen : try_resize ( 75 , 10 ) 110exec ( [[ 111call setline(1, repeat([" abcd\tefgh\tij"], 10)) 112call cursor(1, 1) 113]] ) 114feed ( 'jVjzf' ) 115-- gm 116feed ( 'gmk' ) 117eq ( 18 , fn . virtcol ( '.' )) 118-- g0 119feed ( 'gj0k' ) 120eq ( 1 , fn . virtcol ( '.' )) 121-- g^ 122feed ( 'jg^k' ) 123eq ( 3 , fn . virtcol ( '.' )) 124exec ( 'call cursor(10, 1)' ) 125-- gm 126feed ( 'gmk' ) 127eq ( 18 , fn . virtcol ( '.' )) 128-- g0 129feed ( 'gj0k' ) 130eq ( 1 , fn . virtcol ( '.' )) 131-- g^ 132feed ( 'jg^k' ) 133eq ( 3 , fn . virtcol ( '.' )) 134end ) 135 136-- oldtest: Test_pos_percentage_in_turkish_locale() 137it ( 'viewport position percentage in Turkish locale' , function () 138t . skip ( not t . translations_enabled (), 'N/A: Nvim not built with ENABLE_TRANSLATIONS' ) 139t . skip ( not pcall ( exec , 'lang tr_TR.UTF-8' ), 'Turkish locale not available' ) 140 141local build_dir =t . paths . test_build_dir 142local locale_dir =build_dir .. '/share/locale/tr/LC_MESSAGES' 143 144fn . mkdir ( locale_dir , 'p' ) 145fn . filecopy ( build_dir .. '/src/nvim/po/tr.mo' , locale_dir .. '/nvim.mo' ) 146finally ( function () 147n . rmdir ( vim . fs . dirname ( locale_dir )) 148end ) 149 150clear ( { env ={ LANG ='tr_TR.UTF-8' } } ) 151screen =Screen . new ( 40 , 5 ) 152exec ( 'set ruler' ) 153exec ( 'lang tr_TR.UTF-8' ) 154exec ( 'put =range(1,40)' ) 155exec ( '5' ) 156screen : expect ( [[ 1573 | 158^4 | 1595 | 1606 | 16140 more lines 5,1 %8| 162]] ) 163end ) 164end )