diff options
author | Gregory Anders <greg@gpanders.com> | 2024-11-25 09:00:42 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 15:00:42 +0000 |
commit | a811d4babd22e21a3cd598b097fa0824fcff7fc6 (patch) | |
tree | 8db0e1c5ca343bbd8679fd5d56b5bddb0b2c1234 | |
parent | b47b0b3f757d58a76242ac325a35cac6fbeffc07 (diff) | |
download | rneovim-a811d4babd22e21a3cd598b097fa0824fcff7fc6.tar.gz rneovim-a811d4babd22e21a3cd598b097fa0824fcff7fc6.tar.bz2 rneovim-a811d4babd22e21a3cd598b097fa0824fcff7fc6.zip |
fix(tui): only reset cursor color if it was changed (#31337)
We already track this information so we might as well use it. This
eliminates a bunch of unnecessary OSC sequences.
-rw-r--r-- | src/nvim/tui/tui.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2839a665da..cb893ec777 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -107,7 +107,7 @@ struct TUIData { bool busy, is_invisible, want_invisible; bool cork, overflow; bool set_cursor_color_as_str; - bool cursor_color_changed; + bool cursor_has_color; bool is_starting; bool did_set_grapheme_cluster_mode; FILE *screenshot; @@ -336,7 +336,7 @@ static void terminfo_start(TUIData *tui) tui->cork = false; tui->overflow = false; tui->set_cursor_color_as_str = false; - tui->cursor_color_changed = false; + tui->cursor_has_color = false; tui->showing_mode = SHAPE_IDX_N; tui->unibi_ext.enable_mouse = -1; tui->unibi_ext.disable_mouse = -1; @@ -521,7 +521,7 @@ static void terminfo_stop(TUIData *tui) // Exit alternate screen. unibi_out(tui, unibi_exit_ca_mode); } - if (tui->cursor_color_changed) { + if (tui->cursor_has_color) { unibi_out_ext(tui, tui->unibi_ext.reset_cursor_color); } // Disable bracketed paste @@ -1302,11 +1302,12 @@ static void tui_set_mode(TUIData *tui, ModeShape mode) UNIBI_SET_NUM_VAR(tui->params[0], aep.rgb_bg_color); } unibi_out_ext(tui, tui->unibi_ext.set_cursor_color); - tui->cursor_color_changed = true; + tui->cursor_has_color = true; } - } else if (c.id == 0) { + } else if (c.id == 0 && tui->cursor_has_color) { // No cursor color for this mode; reset to default. tui->want_invisible = false; + tui->cursor_has_color = false; unibi_out_ext(tui, tui->unibi_ext.reset_cursor_color); } |