fix(terminal): don't lose focus on <MouseMove>

(cherry picked from commit e96b3133ef)
This commit is contained in:
zeertzjq
2023-10-31 11:29:24 +08:00
committed by github-actions[bot]
parent 88f0179834
commit edbe109762
2 changed files with 22 additions and 6 deletions

View File

@@ -1485,13 +1485,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;
}

View File

@@ -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)