robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local tt =require ( 'test.functional.testterm' ) 5local describe , it , before_each =t . describe , t . it , t . before_each 6local assert_alive =n . assert_alive 7local clear =n . clear 8local feed =n . feed 9local command =n . command 10local eq =t . eq 11local eval =n . eval 12local api =n . api 13local sleep =vim . uv . sleep 14local retry =t . retry 15local is_os =t . is_os 16 17describe ( ':terminal' , function () 18local screen 19 20before_each ( function () 21clear () 22-- set the statusline to a constant value because of variables like pid 23-- and current directory and to improve visibility of splits 24api . nvim_set_option_value ( 'statusline' , '==========' , {} ) 25screen =tt . setup_screen ( 3 ) 26command ( 'highlight StatusLine NONE' ) 27command ( 'highlight StatusLineNC NONE' ) 28command ( 'highlight StatusLineTerm NONE' ) 29command ( 'highlight StatusLineTermNC NONE' ) 30command ( 'highlight VertSplit NONE' ) 31end ) 32 33it ( 'next to a closing window' , function () 34command ( 'split' ) 35command ( 'terminal' ) 36command ( 'vsplit foo' ) 37eq ( 3 , eval ( "winnr('$')" )) 38feed ( 'ZQ' ) -- Close split, should not crash. #7538 39assert_alive () 40end ) 41 42it ( 'does not change size on WinEnter' , function () 43feed ( '<c-\\><c-n>' ) 44feed ( 'k' ) 45command ( '2split' ) 46screen : expect ( [[ 47^tty ready | 48rows: 5, cols: 50 | 49========== | 50tty ready | 51rows: 5, cols: 50 | 52|*3 53========== | 54| 55]] ) 56command ( 'wincmd p' ) 57screen : expect ( [[ 58tty ready | 59rows: 5, cols: 50 | 60========== | 61^tty ready | 62rows: 5, cols: 50 | 63|*3 64========== | 65| 66]] ) 67end ) 68 69it ( 'does not change size if updated when not visible in any window #19665' , function () 70local channel =api . nvim_get_option_value ( 'channel' , {} ) 71command ( 'enew' ) 72sleep ( 100 ) 73api . nvim_chan_send ( channel , 'foo' ) 74sleep ( 100 ) 75command ( 'bprevious' ) 76screen : expect ( [[ 77tty ready | 78^foo | 79|*8 80]] ) 81end ) 82 83it ( 'forwards resize request to the program' , function () 84feed ( [[<C-\><C-N>G]] ) 85local w1 , h1 =screen . _width - 3 , screen . _height - 2 86local w2 , h2 =w1 - 6 , h1 - 3 87 88if is_os ( 'win' ) then 89-- win: SIGWINCH is unreliable, use a weaker test. #7506 90retry ( 3 , 30000 , function () 91screen : try_resize ( w1 , h1 ) 92screen : expect { any ='rows: 7, cols: 47' } 93screen : try_resize ( w2 , h2 ) 94screen : expect { any ='rows: 4, cols: 41' } 95end ) 96return 97end 98 99screen : try_resize ( w1 , h1 ) 100screen : expect ( [[ 101tty ready | 102rows: 7, cols: 47 | 103|*4 104^ | 105| 106]] ) 107screen : try_resize ( w2 , h2 ) 108screen : expect ( [[ 109tty ready | 110rows: 7, cols: 47 | 111rows: 4, cols: 41 | 112^ | 113| 114]] ) 115end ) 116 117it ( 'stays in terminal mode with <Cmd>wincmd' , function () 118command ( 'terminal' ) 119command ( 'split' ) 120command ( 'terminal' ) 121feed ( 'a<Cmd>wincmd j<CR>' ) 122eq ( 2 , eval ( 'winnr()' )) 123eq ( 't' , eval ( 'mode(1)' )) 124end ) 125 126it ( "non-terminal opened in Terminal mode applies 'scrolloff' #34447" , function () 127api . nvim_set_option_value ( 'scrolloff' , 5 , {} ) 128api . nvim_set_option_value ( 'showtabline' , 0 , {} ) 129screen : try_resize ( 78 , 10 ) 130eq ( { mode ='t' , blocking =false } , api . nvim_get_mode ()) 131n . exec_lua ( [[ 132vim.api.nvim_create_autocmd({ 'BufEnter' }, { 133callback = function() 134vim.schedule(function() vim.fn.line('w0') end) 135end, 136}) 137]] ) 138n . add_builddir_to_rtp () 139n . exec ( 'tab help api-types' ) 140screen : expect ( [[ 141| 142==============================================================================| 143API Definitions *api-definitions* | 144| 145^*api-types* | 146The Nvim C API defines custom types for all function parameters. Some are just| 147typedefs around C99 standard types, others are Nvim-defined data structures. | 148| 149Basic types ~ | 150| 151]] ) 152end ) 153end )