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