diff --git a/helix-tui/src/backend/crossterm.rs b/helix-tui/src/backend/crossterm.rs index 52841f6ef9cc1..aa153335629be 100644 --- a/helix-tui/src/backend/crossterm.rs +++ b/helix-tui/src/backend/crossterm.rs @@ -32,10 +32,12 @@ fn vte_version() -> Option { } /// Describes terminal capabilities like extended underline, truecolor, etc. -#[derive(Copy, Clone, Debug, Default)] +#[derive(Clone, Debug, Default)] struct Capabilities { /// Support for undercurled, underdashed, etc. has_extended_underlines: bool, + /// Support for resetting the cursor style back to normal. + cursor_normal: Option, } impl Capabilities { @@ -54,6 +56,9 @@ impl Capabilities { || t.extended_cap("Su").is_some() || vte_version() >= Some(5102) || matches!(term_program().as_deref(), Some("WezTerm")), + cursor_normal: t + .utf8_string_cap(termini::StringCapability::CursorNormal) + .map(|s| s.to_string()), }, } } @@ -154,7 +159,12 @@ where fn restore(&mut self, config: Config) -> io::Result<()> { // reset cursor shape - write!(self.buffer, "\x1B[0 q")?; + let cursor_normal = self + .capabilities + .cursor_normal + .as_deref() + .unwrap_or("\x1B[0 q"); + write!(self.buffer, "{cursor_normal}")?; if config.enable_mouse_capture { execute!(self.buffer, DisableMouseCapture)?; }