diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 43 | ||||
-rw-r--r-- | test/functional/terminal/mouse_spec.lua | 14 |
2 files changed, 56 insertions, 1 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 857679c4b3..ffdfec4428 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -2,7 +2,9 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim -local wait, execute, eq = helpers.wait, helpers.execute, helpers.eq +local wait = helpers.wait +local eval, execute, source = helpers.eval, helpers.execute, helpers.source +local eq, neq = helpers.eq, helpers.neq describe('terminal buffer', function() @@ -155,5 +157,44 @@ describe('terminal buffer', function() :bnext | ]]) end) + + it('handles loss of focus gracefully', function() + -- Temporarily change the statusline to avoid printing the file name, which + -- varies be where the test is run. + nvim('set_option', 'statusline', '==========') + execute('set laststatus=0') + + -- Save the buffer number of the terminal for later testing. + local tbuf = eval('bufnr("%")') + + source([[ + function! SplitWindow() + new + call feedkeys("iabc\<Esc>") + endfunction + + startinsert + call jobstart(['sh', '-c', 'exit'], {'on_exit': function("SplitWindow")}) + call feedkeys("\<C-\>", 't') " vim will expect <C-n>, but be exited out of + " the terminal before it can be entered. + ]]) + + -- We should be in a new buffer now. + screen:expect([[ + ab^c | + ~ | + ========== | + rows: 2, cols: 50 | + {2: } | + {1:========== }| + | + ]]) + + neq(tbuf, eval('bufnr("%")')) + execute('quit!') -- Should exit the new window, not the terminal. + eq(tbuf, eval('bufnr("%")')) + + execute('set laststatus=1') -- Restore laststatus to the default. + end) end) diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua index b8f6214f8f..4def4dd7f8 100644 --- a/test/functional/terminal/mouse_spec.lua +++ b/test/functional/terminal/mouse_spec.lua @@ -50,6 +50,20 @@ describe('terminal mouse', function() ]]) end) + it('will exit focus after <C-\\>, then scrolled', function() + feed('<C-\\>') + feed('<MouseDown><0,0>') + screen:expect([[ + line23 | + line24 | + line25 | + line26 | + line27 | + ^line28 | + | + ]]) + end) + describe('with mouse events enabled by the program', function() before_each(function() thelpers.enable_mouse() |