diff options
-rw-r--r-- | src/nvim/terminal.c | 20 | ||||
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/terminal/mouse_spec.lua | 14 |
3 files changed, 31 insertions, 10 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 9f4d81be19..ed1a8f32b3 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -376,6 +376,8 @@ void terminal_enter(bool process_deferred) int c; bool close = false; + bool got_bs = false; // True if the last input was <C-\> + while (term->buf == curbuf) { if (process_deferred) { event_enable_deferred(); @@ -388,14 +390,6 @@ void terminal_enter(bool process_deferred) } switch (c) { - case Ctrl_BSL: - c = safe_vgetc(); - if (c == Ctrl_N) { - goto end; - } - terminal_send_key(term, c); - break; - case K_LEFTMOUSE: case K_LEFTDRAG: case K_LEFTRELEASE: @@ -416,12 +410,22 @@ void terminal_enter(bool process_deferred) event_process(); break; + case Ctrl_N: + if (got_bs) { + goto end; + } + default: + if (c == Ctrl_BSL && !got_bs) { + got_bs = true; + break; + } if (term->closed) { close = true; goto end; } + got_bs = false; terminal_send_key(term, c); } } diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 0756508a4c..ffdfec4428 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -170,15 +170,18 @@ describe('terminal buffer', function() 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 | @@ -188,7 +191,7 @@ describe('terminal buffer', function() ]]) neq(tbuf, eval('bufnr("%")')) - execute('quit') -- Should exit the new window, not the terminal. + execute('quit!') -- Should exit the new window, not the terminal. eq(tbuf, eval('bufnr("%")')) execute('set laststatus=1') -- Restore laststatus to the default. 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() |