aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <6256228+seandewar@users.noreply.github.com>2025-02-19 10:47:44 +0000
committerGitHub <noreply@github.com>2025-02-19 10:47:44 +0000
commitf3ce67549c946815e64845f27f6f46f1aaeb5ec6 (patch)
tree19f5b8ff054930568d31a057f3e3f3ecfdb0835a /src
parenta3eb49f6382ba6fd6a61ecfebd7b526fa9730e29 (diff)
downloadrneovim-f3ce67549c946815e64845f27f6f46f1aaeb5ec6.tar.gz
rneovim-f3ce67549c946815e64845f27f6f46f1aaeb5ec6.tar.bz2
rneovim-f3ce67549c946815e64845f27f6f46f1aaeb5ec6.zip
fix(terminal): avoid more `busy_start` lacking `busy_stop` (#32509)
Problem: after #32458, it may still be possible for `busy_start` UI events to be emitted without matching `busy_stop`s in the terminal. Solution: do `terminal_enter`'s cursor visibility check immediately after setting/restoring State so it occurs before events. This ensures that if pending escape sequences are processed while in `terminal_enter`, the cursor's initial visibility is set before `is_focused` is checked by `term_settermprop`. As a result, we can move the call to `showmode` back to where it was originally.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/terminal.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 61b55f71de..47630ddea9 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -662,6 +662,10 @@ bool terminal_enter(void)
State = MODE_TERMINAL;
mapped_ctrl_c |= MODE_TERMINAL; // Always map CTRL-C to avoid interrupt.
RedrawingDisabled = false;
+ if (!s->term->cursor.visible) {
+ // Hide cursor if it should be hidden. Do so right after setting State, before events.
+ ui_busy_start();
+ }
// Disable these options in terminal-mode. They are nonsense because cursor is
// placed at end of buffer to "follow" output. #11072
@@ -693,14 +697,10 @@ bool terminal_enter(void)
refresh_cursor(s->term);
adjust_topline(s->term, buf, 0); // scroll to end
+ showmode();
curwin->w_redr_status = true; // For mode() in statusline. #8323
redraw_custom_title_later();
- if (!s->term->cursor.visible) {
- // Hide cursor if it should be hidden
- ui_busy_start();
- }
ui_cursor_shape();
- showmode();
apply_autocmds(EVENT_TERMENTER, NULL, NULL, false, curbuf);
may_trigger_modechanged();
@@ -716,6 +716,11 @@ bool terminal_enter(void)
}
State = save_state;
RedrawingDisabled = s->save_rd;
+ if (!s->term->cursor.visible) {
+ // If cursor was hidden, show it again. Do so right after restoring State, before events.
+ ui_busy_stop();
+ }
+
apply_autocmds(EVENT_TERMLEAVE, NULL, NULL, false, curbuf);
// Restore the terminal cursor to what is set in 'guicursor'
@@ -746,10 +751,6 @@ bool terminal_enter(void)
} else {
unshowmode(true);
}
- if (!s->term->cursor.visible) {
- // If cursor was hidden, show it again
- ui_busy_stop();
- }
ui_cursor_shape();
if (s->close) {
bool wipe = s->term->buf_handle != 0;