aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-29 22:29:10 +0800
committerGitHub <noreply@github.com>2024-03-29 22:29:10 +0800
commit74776dfb2ac497ab63a80ceea07b38c142b2c048 (patch)
tree67e900ab5107e697c2c6f2fe6174c4d9fb368ba3
parent5a5d26b4abdfc32c0e538a7a4b0d73c6827f0e5b (diff)
downloadrneovim-74776dfb2ac497ab63a80ceea07b38c142b2c048.tar.gz
rneovim-74776dfb2ac497ab63a80ceea07b38c142b2c048.tar.bz2
rneovim-74776dfb2ac497ab63a80ceea07b38c142b2c048.zip
fix(terminal): fix duplicate recording with mouse click (#28103)
-rw-r--r--src/nvim/terminal.c5
-rw-r--r--test/functional/terminal/mouse_spec.lua6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 3734d55a5b..9033e00f3d 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -1631,7 +1631,10 @@ end:
return false;
}
- ins_char_typebuf(vgetc_char, vgetc_mod_mask);
+ int len = ins_char_typebuf(vgetc_char, vgetc_mod_mask);
+ if (KeyTyped) {
+ ungetchars(len);
+ }
return true;
}
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index 0395d5ee16..08ec7b97cf 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -41,6 +41,7 @@ describe(':terminal mouse', function()
end)
it('will exit focus and trigger Normal mode mapping on mouse click', function()
+ feed([[<C-\><C-N>qri]])
command('let g:got_leftmouse = 0')
command('nnoremap <LeftMouse> <Cmd>let g:got_leftmouse = 1<CR>')
eq('t', eval('mode(1)'))
@@ -48,9 +49,12 @@ describe(':terminal mouse', function()
feed('<LeftMouse>')
eq('nt', eval('mode(1)'))
eq(1, eval('g:got_leftmouse'))
+ feed('q')
+ eq('i<LeftMouse>', eval('keytrans(@r)'))
end)
it('will exit focus and trigger Normal mode mapping on mouse click with modifier', function()
+ feed([[<C-\><C-N>qri]])
command('let g:got_ctrl_leftmouse = 0')
command('nnoremap <C-LeftMouse> <Cmd>let g:got_ctrl_leftmouse = 1<CR>')
eq('t', eval('mode(1)'))
@@ -58,6 +62,8 @@ describe(':terminal mouse', function()
feed('<C-LeftMouse>')
eq('nt', eval('mode(1)'))
eq(1, eval('g:got_ctrl_leftmouse'))
+ feed('q')
+ eq('i<C-LeftMouse>', eval('keytrans(@r)'))
end)
it('will exit focus on <C-\\> + mouse-scroll', function()