fix(tui): don't forget to update cursor visibility (#26523)

This commit is contained in:
zeertzjq 2023-12-12 09:44:46 +08:00 committed by GitHub
parent 8097b4a725
commit b76cc974b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 4 deletions

View File

@ -2255,6 +2255,11 @@ static void augment_terminfo(TUIData *tui, const char *term, int vte_version, in
}
}
static bool should_invisible(TUIData *tui)
{
return tui->busy || tui->want_invisible;
}
/// Write the sequence to begin flushing output to `buf`.
/// If 'termsync' is set and the terminal supports synchronized output, begin synchronized update.
/// Otherwise, hide the cursor to avoid cursor jumping.
@ -2298,11 +2303,10 @@ static size_t flush_buf_end(TUIData *tui, char *buf, size_t len)
}
const char *str = NULL;
bool should_invisible = tui->busy || tui->want_invisible;
if (tui->is_invisible && !should_invisible) {
if (tui->is_invisible && !should_invisible(tui)) {
str = unibi_get_str(tui->ut, unibi_cursor_normal);
tui->is_invisible = false;
} else if (!tui->is_invisible && should_invisible) {
} else if (!tui->is_invisible && should_invisible(tui)) {
str = unibi_get_str(tui->ut, unibi_cursor_invisible);
tui->is_invisible = true;
}
@ -2322,7 +2326,7 @@ static void flush_buf(TUIData *tui)
char pre[32];
char post[32];
if (tui->bufpos <= 0) {
if (tui->bufpos <= 0 && tui->is_invisible == should_invisible(tui)) {
return;
}

View File

@ -1714,6 +1714,36 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
end)
it('cursor is not hidden on incsearch with no match', function()
feed_data('ifoo\027')
feed_data('/foo')
screen:expect([[
{1:foo} |
{4:~ }|*3
{5:[No Name] [+] }|
/foo{1: } |
{3:-- TERMINAL --} |
]])
screen:sleep(10)
feed_data('b')
screen:expect([[
foo |
{4:~ }|*3
{5:[No Name] [+] }|
/foob{1: } |
{3:-- TERMINAL --} |
]])
screen:sleep(10)
feed_data('a')
screen:expect([[
foo |
{4:~ }|*3
{5:[No Name] [+] }|
/fooba{1: } |
{3:-- TERMINAL --} |
]])
end)
end)
describe('TUI', function()