aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordm1try <me@dmitry.it>2021-12-09 19:44:09 +0300
committerdm1try <me@dmitry.it>2021-12-10 00:53:30 +0300
commitc96f7e29dc69976c2f5efa0a59710ef8416bb982 (patch)
tree009d2f1595001c027a66b13a583fd4b0fd8797ba
parent2fe60905f6e12b3cae5c9ca2d1456fe23501be61 (diff)
downloadrneovim-c96f7e29dc69976c2f5efa0a59710ef8416bb982.tar.gz
rneovim-c96f7e29dc69976c2f5efa0a59710ef8416bb982.tar.bz2
rneovim-c96f7e29dc69976c2f5efa0a59710ef8416bb982.zip
fix(terminal): ignore left-release mouse action
if it is not proccesed by the terminal program to prevent leaving Terminal mode after using a mouse for window switching closes #9483 closes #8691
-rw-r--r--src/nvim/terminal.c6
-rw-r--r--test/functional/terminal/mouse_spec.lua6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index afebda4948..c272fdb7b0 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -1296,6 +1296,12 @@ static bool send_mouse_event(Terminal *term, int c)
return mouse_win == curwin;
}
+ // ignore left release action if it was not proccessed above
+ // to prevent leaving Terminal mode after entering to it using a mouse
+ if (c == K_LEFTRELEASE && mouse_win->w_buffer->terminal == term) {
+ return false;
+ }
+
end:
ins_char_typebuf(c);
return true;
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index 3d8441b93c..833ded9479 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -45,6 +45,12 @@ describe(':terminal mouse', function()
eq('nt', eval('mode(1)'))
end)
+ it('does not leave terminal mode on left-release', function()
+ if helpers.pending_win32(pending) then return end
+ feed('<LeftRelease>')
+ eq('t', eval('mode(1)'))
+ end)
+
describe('with mouse events enabled by the program', function()
before_each(function()
thelpers.enable_mouse()