summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMat Jones <mat@mjones.network>2021-12-17 07:14:45 -0500
committerGitHub <noreply@github.com>2021-12-17 12:14:45 +0000
commit133971179eccb8a9846ad90dcf00f02d684c0bea (patch)
tree00f5cf79a2c537f1a08e94880a67740e46191544
parent059e858a007391a0019988e941ae489996cb4210 (diff)
Add Alt+backspace and Ctrl+u keybinds for deleting by word and by line, respectively (#243)
* remove unused environment var loading entire history into an env var * Add Alt+backspace and Ctrl+u keybinds for deleting by word and by line, respectively
-rw-r--r--src/command/search.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/command/search.rs b/src/command/search.rs
index 00e11f525..922f74687 100644
--- a/src/command/search.rs
+++ b/src/command/search.rs
@@ -207,6 +207,23 @@ async fn key_handler(
app.input.pop();
query_results(app, search_mode, db).await.unwrap();
}
+ // \u{7f} is escape sequence for backspace
+ Key::Alt('\u{7f}') => {
+ let words: Vec<&str> = app.input.split(' ').collect();
+ if words.is_empty() {
+ return None;
+ }
+ if words.len() == 1 {
+ app.input = String::from("");
+ } else {
+ app.input = words[0..(words.len() - 1)].join(" ");
+ }
+ query_results(app, search_mode, db).await.unwrap();
+ }
+ Key::Ctrl('u') => {
+ app.input = String::from("");
+ query_results(app, search_mode, db).await.unwrap();
+ }
Key::Down | Key::Ctrl('n') => {
let i = match app.results_state.selected() {
Some(i) => {