terminal: preserve mode when using <Cmd>wincmd in terminal mode (#12254)

This commit is contained in:
Ghjuvan Lacambre 2020-06-22 23:22:58 +02:00 committed by GitHub
parent 1619410a05
commit 721f69c4af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -489,7 +489,17 @@ static int terminal_execute(VimState *state, int key)
terminal_send_key(s->term, key);
}
return curbuf->handle == s->term->buf_handle;
if (curbuf->terminal == NULL) {
return 0;
}
if (s->term != curbuf->terminal) {
invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1);
invalidate_terminal(curbuf->terminal,
curbuf->terminal->cursor.row,
curbuf->terminal->cursor.row + 1);
s->term = curbuf->terminal;
}
return 1;
}
void terminal_destroy(Terminal *term)

View File

@ -103,4 +103,14 @@ describe(':terminal', function()
|
]])
end)
it('stays in terminal mode with <Cmd>wincmd', function()
command('terminal')
command('split')
command('terminal')
feed('a<Cmd>wincmd j<CR>')
eq(2, eval("winnr()"))
eq('t', eval('mode()'))
end)
end)