From dccdb2c33f40b05377297eff9fa2090442e77286 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Mon, 12 Jun 2023 08:48:32 +1200 Subject: [PATCH] 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. --- atuin/src/command/client/search/interactive.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs index 5076d52..eec7ac8 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()) {}