From d80169ceff37f910721454d78bf5143b7e25d7d4 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 27 Oct 2019 23:59:15 -0700 Subject: [PATCH] Avoid accidental application mode delete output in key processing I thought that I'd broken something with the DEL processing in vim with the new frontend but it turned out that the other frontend was emitting BS always and that I'd actuall unbroken passing DEL through and that other layers were translating DEL into an application cursor mode output for DEL that emits a totally different sequence. This diff preserves DEL and disables that other sequence. Will follow up with some explicit configuration to control this behavior, but in the short term, the default behavior should be much closer to what people actually want and expect! refs: https://github.com/wez/wezterm/issues/52 --- term/src/terminalstate.rs | 3 ++- termwiz/src/input.rs | 5 +++-- window/src/os/macos/window.rs | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index ba2280b91..2665c5c60 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -850,7 +850,8 @@ impl TerminalState { (Escape, ..) => "\x1b", // Delete (Char('\x7f'), _, _, _, false) | (Delete, _, _, _, false) => "\x7f", - (Char('\x7f'), ..) | (Delete, ..) => "\x1b[3~", + // TODO: application delete key? See https://github.com/wez/wezterm/issues/52 + (Char('\x7f'), _, _, _, true) | (Delete, _, _, _, true) => "\x7f", // "\x1b[3~" (Char(c), CTRL, _, SHIFT, _) if c <= 0xff as char && c > 0x40 as char => { // If shift is held we have C == 0x43 and want to translate diff --git a/termwiz/src/input.rs b/termwiz/src/input.rs index 383eba783..316c478ad 100644 --- a/termwiz/src/input.rs +++ b/termwiz/src/input.rs @@ -560,7 +560,8 @@ impl InputParser { for (keycode, c) in &[ (KeyCode::Insert, b'2'), - (KeyCode::Delete, b'3'), + // TODO: application delete key? See https://github.com/wez/wezterm/issues/52 + // (KeyCode::Delete, b'3'), (KeyCode::Home, b'1'), (KeyCode::End, b'4'), (KeyCode::PageUp, b'5'), @@ -579,7 +580,7 @@ impl InputParser { map.insert( &[0x7f], InputEvent::Key(KeyEvent { - key: KeyCode::Backspace, + key: KeyCode::Delete, modifiers: Modifiers::NONE, }), ); diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index d90a4ab5e..a26d341d1 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -643,8 +643,6 @@ impl WindowView { '\u{f72b}' => KeyCode::End, '\u{f72c}' => KeyCode::PageUp, '\u{f72d}' => KeyCode::PageDown, - // rewrite Del to Backspace - '\u{7f}' => KeyCode::Char('\u{8}'), _ => KeyCode::Char(first_char), } } else {