From a3eff66e313b89cf721ad70ea34c41b7425200c1 Mon Sep 17 00:00:00 2001 From: Kyle <50718101+kylesower@users.noreply.github.com> Date: Thu, 30 Jul 2026 02:34:26 -0500 Subject: [PATCH] fix(tui): xterm default cursor style #41050 Problem: xterm doesn't reset to user configured default with the sequence `\x1b[0 q`. Solution: Restore old behavior: if the reset cursor style terminfo entry is absent, xterm's sequence should set the cursor to steady block, which is the xterm default. In the near future, they may support another option (`\x1b[7 q`) to reset to the user configured default. --- src/nvim/tui/tui.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 8ba17d4362..d9b360a570 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2363,9 +2363,7 @@ static void patch_terminfo_bugs(TUIData *tui, const char *term, const char *colo // DECSCUSR (cursor shape) is widely supported. // https://github.com/gnachman/iTerm2/pull/92 if (!bsdvt - && (xterm // anything claiming xterm compat - // per MinTTY 0.4.3-1 release notes from 2009 - || putty + && (putty // per MinTTY 0.4.3-1 release notes from 2009 // per https://chromium.googlesource.com/apps/libapps/+/a5fb83c190aa9d74f4a9bca233dac6be2664e9e9/hterm/doc/ControlSequences.md || hterm // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 @@ -2411,6 +2409,11 @@ static void patch_terminfo_bugs(TUIData *tui, const char *term, const char *colo "%e%{0}" // anything else "%;" "%dc"); terminfo_set_str(tui, kTerm_reset_cursor_style, "\x1b[?c"); + } else if (!bsdvt && xterm) { + terminfo_set_if_empty(tui, kTerm_set_cursor_style, "\x1b[%p1%d q"); + // xterm has a configurable cursor, but the default is 2, and 0 doesn't + // reset to default. #41047 + terminfo_set_if_empty(tui, kTerm_reset_cursor_style, "\x1b[2 q"); } xfree(xterm_version);