diff --git a/term/src/lib.rs b/term/src/lib.rs index 04dd2386c..3d5599c7d 100644 --- a/term/src/lib.rs +++ b/term/src/lib.rs @@ -107,7 +107,8 @@ mod test; /// certain feature sets. pub const DEVICE_IDENT: &[u8] = b"\x1b[?6c"; -pub const CSI: &[u8] = b"\x1b["; +pub const CSI: &str = "\x1b["; pub const OSC: &[u8] = b"\x1b]"; pub const ST: &[u8] = b"\x1b\\"; +pub const SS3: &str = "\x1bO"; pub const DCS: &[u8] = b"\x1bP"; diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index add87bc2b..d1595c41d 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -644,19 +644,22 @@ impl TerminalState { }; let csi_or_ss3 = if force_app - || (self.application_cursor_keys - && self.dec_ansi_mode - && self.application_keypad) - { + || ( + self.application_cursor_keys + // Strict reading of DECCKM suggests that application_cursor_keys + // only applies when DECANM and DECKPAM are active, but that seems + // to break unmodified cursor keys in vim + /* && self.dec_ansi_mode && self.application_keypad */ + ) { // Use SS3 in application mode - "\x1bO" + SS3 } else { // otherwise use regular CSI - "\x1b[" + CSI }; if mods.contains(KeyModifiers::SHIFT) || mods.contains(KeyModifiers::CTRL) { - write!(buf, "{}1;{}{}", csi_or_ss3, 1 + encode_modifiers(mods), c)?; + write!(buf, "{}1;{}{}", CSI, 1 + encode_modifiers(mods), c)?; } else { if mods.contains(KeyModifiers::ALT) { buf.push(0x1b as char);