diff options
author | Jan Larres <jan@majutsushi.net> | 2023-06-12 08:48:32 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-11 21:48:32 +0100 |
commit | dccdb2c33f40b05377297eff9fa2090442e77286 (patch) | |
tree | e667e9545cbc8715d1bfae9ad70b57e36d985720 | |
parent | a224a8e4d34c8c1183bfb46604a59fe3b3f55eae (diff) |
Make Ctrl-d behaviour match other tools (#1040)
With this change Ctrl-d behaves differently depending on whether there
is any input text available. If there is, it will delete the character
to the right of the cursor if there is any. If there isn't it will
instead quit interactive mode and leave the original shell command line
unchanged.
This matches other line-based tools like bash and fzf.
-rw-r--r-- | atuin/src/command/client/search/interactive.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs index 5076d528..eec7ac8d 100644 --- a/atuin/src/command/client/search/interactive.rs +++ b/atuin/src/command/client/search/interactive.rs @@ -105,7 +105,7 @@ impl State { // reset the state, will be set to true later if user really did change it self.switched_search_mode = false; match input.code { - KeyCode::Char('c' | 'd' | 'g') if ctrl => return Some(RETURN_ORIGINAL), + KeyCode::Char('c' | 'g') if ctrl => return Some(RETURN_ORIGINAL), KeyCode::Esc => { return Some(match settings.exit_mode { ExitMode::ReturnOriginal => RETURN_ORIGINAL, @@ -165,6 +165,12 @@ impl State { KeyCode::Delete => { self.search.input.remove(); } + KeyCode::Char('d') if ctrl => { + if self.search.input.as_str().is_empty() { + return Some(RETURN_ORIGINAL); + } + self.search.input.remove(); + } KeyCode::Char('w') if ctrl => { // remove the first batch of whitespace while matches!(self.search.input.back(), Some(c) if c.is_whitespace()) {} |