mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 03:58:32 +00:00
term: after <C-\>, resume normal input loop
Pressing <C-\> and then a mouse click will insert the click into the terminal as if a keyboard button had been pressed. Keep track of whether the last input was <C-\> and only call terminal_send_key() if the next input is a key press.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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.
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user