aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-10-31 12:05:37 +0800
committerGitHub <noreply@github.com>2023-10-31 12:05:37 +0800
commitc881092ffe9d6760d08efcd4dfb02efcb60cc706 (patch)
treecd430c42c948b3e178b2efe298c01ab4c127cf0b
parent6d1a2f2c3c51560555ea6f7867273635d07eb287 (diff)
downloadrneovim-c881092ffe9d6760d08efcd4dfb02efcb60cc706.tar.gz
rneovim-c881092ffe9d6760d08efcd4dfb02efcb60cc706.tar.bz2
rneovim-c881092ffe9d6760d08efcd4dfb02efcb60cc706.zip
fix(terminal): don't lose focus on <MouseMove> (#25845)
-rw-r--r--src/nvim/terminal.c9
-rw-r--r--test/functional/terminal/mouse_spec.lua19
2 files changed, 22 insertions, 6 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index a564738243..fbfe8c04a6 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -1506,13 +1506,14 @@ static bool send_mouse_event(Terminal *term, int c)
return mouse_win == curwin;
}
- // ignore left release action if it was not processed above
- // to prevent leaving Terminal mode after entering to it using a mouse
- if (c == K_LEFTRELEASE && mouse_win->w_buffer->terminal == term) {
+end:
+ // Ignore left release action if it was not forwarded to prevent
+ // leaving Terminal mode after entering to it using a mouse.
+ if ((c == K_LEFTRELEASE && mouse_win != NULL && mouse_win->w_buffer->terminal == term)
+ || c == K_MOUSEMOVE) {
return false;
}
-end:
ins_char_typebuf(vgetc_char, vgetc_mod_mask);
return true;
}
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index 6dccd14994..92d9b03b45 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -67,8 +67,23 @@ describe(':terminal mouse', function()
eq('nt', eval('mode(1)'))
end)
- it('does not leave terminal mode on left-release', function()
- feed('<LeftRelease>')
+ it('will not exit focus on left-release', function()
+ eq('t', eval('mode(1)'))
+ feed('<LeftRelease><0,0>')
+ eq('t', eval('mode(1)'))
+ command('setlocal number')
+ eq('t', eval('mode(1)'))
+ feed('<LeftRelease><0,0>')
+ eq('t', eval('mode(1)'))
+ end)
+
+ it('will not exit focus on mouse movement', function()
+ eq('t', eval('mode(1)'))
+ feed('<MouseMove><0,0>')
+ eq('t', eval('mode(1)'))
+ command('setlocal number')
+ eq('t', eval('mode(1)'))
+ feed('<MouseMove><0,0>')
eq('t', eval('mode(1)'))
end)