From b76cc974b9a5dd206f01872f78e6346e54fb5170 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 12 Dec 2023 09:44:46 +0800 Subject: [PATCH] fix(tui): don't forget to update cursor visibility (#26523) --- src/nvim/tui/tui.c | 12 +++++++---- test/functional/terminal/tui_spec.lua | 30 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index eac59eacac..70df1464ed 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -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; } diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 45be0dd3a1..a4e3c1d199 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -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()