mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-07 17:04:51 +01:00
feat(search): process [C-h] and [C-?] as representations of backspace (#1857)
In the conventional terminal protocol, Backspace can be transmitted as the code \x08 or \x7F depending on the terminal. Ctrl+Backspace can also be transmitted as the code \x08 or \x7F. These overlap with the code for Ctrl+H and Ctrl+?. The crossterm library does not try to handle these terminal dependencies (probably because it is hard to resolve it perfectly). To provide a consistent experience among terminals, we assign to C-h and C-? the same feature as backspace. Note: The crossterm seems to produce Ctrl+Backspace only in the extended keyboard protocol, so we can trust crossterm particularly for Ctrl+Backspace. For this reason, we keep the feature of removing a backward word by Ctrl+Backspace. https://github.com/atuinsh/atuin/issues/1753
This commit is contained in:
parent
c00e54c54c
commit
0d3741f1cc
@ -379,6 +379,21 @@ impl State {
|
||||
KeyCode::Backspace => {
|
||||
self.search.input.back();
|
||||
}
|
||||
KeyCode::Char('h' | '?') if ctrl => {
|
||||
// Depending on the terminal, [Backspace] can be transmitted as
|
||||
// \x08 or \x7F. Also, [Ctrl+Backspace] can be transmitted as
|
||||
// \x08 or \x7F or \x1F. On the other hand, [Ctrl+h] and
|
||||
// [Ctrl+?] are also transmitted as \x08 or \x7F by the
|
||||
// terminals.
|
||||
//
|
||||
// The crossterm library translates \x08 and \x7F to C-h and
|
||||
// Backspace, respectively. With the extended keyboard
|
||||
// protocol enabled, crossterm can faithfully translate
|
||||
// [Ctrl+h] and [Ctrl+?] to C-h and C-?. There is no perfect
|
||||
// solution, but we treat C-h and C-? the same as backspace to
|
||||
// suppress quirks as much as possible.
|
||||
self.search.input.back();
|
||||
}
|
||||
KeyCode::Delete if ctrl => self
|
||||
.search
|
||||
.input
|
||||
|
Loading…
Reference in New Issue
Block a user