aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/buffer_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal/buffer_spec.lua')
-rw-r--r--test/functional/terminal/buffer_spec.lua43
1 files changed, 42 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)