aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crates/atuin/src/command/client/search/cursor.rs10
-rw-r--r--crates/atuin/src/command/client/search/interactive.rs8
-rw-r--r--crates/atuin/src/command/client/search/keybindings/actions.rs6
-rw-r--r--docs/docs/configuration/advanced-key-binding.md2
4 files changed, 26 insertions, 0 deletions
diff --git a/crates/atuin/src/command/client/search/cursor.rs b/crates/atuin/src/command/client/search/cursor.rs
index e0c9595b..ebe8bbe5 100644
--- a/crates/atuin/src/command/client/search/cursor.rs
+++ b/crates/atuin/src/command/client/search/cursor.rs
@@ -192,6 +192,16 @@ impl Cursor {
self.index = 0;
}
+ pub fn clear_to_start(&mut self) {
+ self.source.replace_range(..self.index, "");
+ self.index = 0;
+ }
+
+ pub fn clear_to_end(&mut self) {
+ self.source.replace_range(self.index.., "");
+ self.index = self.source.len();
+ }
+
pub fn end(&mut self) {
self.index = self.source.len();
}
diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs
index bcbb1307..1a51c36b 100644
--- a/crates/atuin/src/command/client/search/interactive.rs
+++ b/crates/atuin/src/command/client/search/interactive.rs
@@ -482,6 +482,14 @@ impl State {
self.search.input.clear();
InputAction::Continue
}
+ Action::ClearToStart => {
+ self.search.input.clear_to_start();
+ InputAction::Continue
+ }
+ Action::ClearToEnd => {
+ self.search.input.clear_to_end();
+ InputAction::Continue
+ }
// -- List navigation (invert-aware) --
Action::SelectNext => {
diff --git a/crates/atuin/src/command/client/search/keybindings/actions.rs b/crates/atuin/src/command/client/search/keybindings/actions.rs
index da8a1d42..5242b383 100644
--- a/crates/atuin/src/command/client/search/keybindings/actions.rs
+++ b/crates/atuin/src/command/client/search/keybindings/actions.rs
@@ -20,6 +20,8 @@ pub enum Action {
DeleteWordAfter,
DeleteToWordBoundary,
ClearLine,
+ ClearToStart,
+ ClearToEnd,
// List navigation
SelectNext,
@@ -99,6 +101,8 @@ impl Action {
"delete-word-after" => Ok(Action::DeleteWordAfter),
"delete-to-word-boundary" => Ok(Action::DeleteToWordBoundary),
"clear-line" => Ok(Action::ClearLine),
+ "clear-to-start" => Ok(Action::ClearToStart),
+ "clear-to-end" => Ok(Action::ClearToEnd),
"select-next" => Ok(Action::SelectNext),
"select-previous" => Ok(Action::SelectPrevious),
@@ -157,6 +161,8 @@ impl Action {
Action::DeleteWordAfter => "delete-word-after".to_string(),
Action::DeleteToWordBoundary => "delete-to-word-boundary".to_string(),
Action::ClearLine => "clear-line".to_string(),
+ Action::ClearToStart => "clear-to-start".to_string(),
+ Action::ClearToEnd => "clear-to-end".to_string(),
Action::SelectNext => "select-next".to_string(),
Action::SelectPrevious => "select-previous".to_string(),
diff --git a/docs/docs/configuration/advanced-key-binding.md b/docs/docs/configuration/advanced-key-binding.md
index c8ad3347..9183ca8b 100644
--- a/docs/docs/configuration/advanced-key-binding.md
+++ b/docs/docs/configuration/advanced-key-binding.md
@@ -140,6 +140,8 @@ Actions are specified as kebab-case strings.
| `delete-word-after` | Delete the word after the cursor |
| `delete-to-word-boundary` | Delete to the next word boundary (like `ctrl-w`) |
| `clear-line` | Clear the entire input line |
+| `clear-to-start` | Clear the start of input line |
+| `clear-to-end` | Clear the end of input line |
### List navigation