aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoe Hermaszewski <git@monoid.al>2015-11-20 18:47:20 +0000
committerMarco Hinz <mh.codebro@gmail.com>2015-11-23 13:18:27 +0100
commit442cd0672b567cce56dd45e731ec1cc3b71b7cf4 (patch)
tree334a3fce2f9ee94351b046d824284a73c77f0275 /test
parent321db59ca1dc304feb3e00c10ca3e89c1de616e7 (diff)
downloadrneovim-442cd0672b567cce56dd45e731ec1cc3b71b7cf4.tar.gz
rneovim-442cd0672b567cce56dd45e731ec1cc3b71b7cf4.tar.bz2
rneovim-442cd0672b567cce56dd45e731ec1cc3b71b7cf4.zip
Enable focus events in cmdline and terminal modes
This change adds switch cases for K_FOCUSGAINED and K_FOCUSLOST to the input handling functions in ex_getln.c and terminal.c. The handling is identical to what's found in edit.c (just calling apply_autocmds). If one enters cmdline-mode by feeding `:` and sends a focuslost event (by leaving the window for example) the text `<FocusLost>` will be inserted into the command line. There is similar behaviour in terminal mode. This patch corrects this behavior to fire the apropriate autocmd instead. Fixes #3714
Diffstat (limited to 'test')
-rw-r--r--test/functional/terminal/tui_spec.lua77
1 files changed, 77 insertions, 0 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 9a1fdfca55..92cd9567d2 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -5,6 +5,7 @@ local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
local feed = thelpers.feed_data
local execute = helpers.execute
+local nvim_dir = helpers.nvim_dir
describe('tui', function()
local screen
@@ -150,8 +151,11 @@ describe('tui', function()
end)
it('can handle focus events', function()
+ execute('set noshowmode')
execute('autocmd FocusGained * echo "gained"')
execute('autocmd FocusLost * echo "lost"')
+
+ -- In normal mode
feed('\x1b[I')
screen:expect([[
{1: } |
@@ -173,6 +177,79 @@ describe('tui', function()
lost |
-- TERMINAL -- |
]])
+
+ -- In insert mode
+ feed('i')
+ feed('\x1b[I')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ gained |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ lost |
+ -- TERMINAL -- |
+ ]])
+
+ -- In command-line mode
+ feed('\x1b')
+ feed(':')
+ feed('\x1b[I')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ g{1:a}ined |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ l{1:o}st |
+ -- TERMINAL -- |
+ ]])
+
+ -- In terminal mode
+ execute('set shell='..nvim_dir..'/shell-test')
+ execute('set laststatus=0')
+ feed('\x1b')
+ execute('terminal')
+ feed('\x1b[I')
+ screen:expect([[
+ ready $ |
+ [Process exited 0]{1: } |
+ |
+ |
+ |
+ gained |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ ready $ |
+ [Process exited 0]{1: } |
+ |
+ |
+ |
+ lost |
+ -- TERMINAL -- |
+ ]])
end)
end)