aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/input.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-12-20 04:27:08 +0000
committerGitHub <noreply@github.com>2020-12-20 04:27:08 +0000
commitf016a209b4ac1bfa6625b9d30e6f69bc91bc7545 (patch)
treef3808e085b53f84203c322bdd408746a8c9dde1d /alacritty/src/input.rs
parent8a7f8c9d3eca214578439da417d37395971a711d (diff)
downloadr-alacritty-f016a209b4ac1bfa6625b9d30e6f69bc91bc7545.tar.gz
r-alacritty-f016a209b4ac1bfa6625b9d30e6f69bc91bc7545.tar.bz2
r-alacritty-f016a209b4ac1bfa6625b9d30e6f69bc91bc7545.zip
Add search history support
This adds a history to the regex search limited to at most 255 entries. Whenever a search is either confirmed or cancelled, the last regex is entered into the history and can be accessed when a new search is started. This should help users recover complicated search regexes after accidentally discarding them, or handle repeated searches with the same regexes. Fixes #4095.
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r--alacritty/src/input.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs
index d5afbbd2..313c7051 100644
--- a/alacritty/src/input.rs
+++ b/alacritty/src/input.rs
@@ -97,7 +97,9 @@ pub trait ActionContext<T: EventListener> {
fn confirm_search(&mut self);
fn cancel_search(&mut self);
fn search_input(&mut self, c: char);
- fn pop_word_search(&mut self);
+ fn search_pop_word(&mut self);
+ fn search_history_previous(&mut self);
+ fn search_history_next(&mut self);
fn advance_search_origin(&mut self, direction: Direction);
fn search_direction(&self) -> Direction;
fn search_active(&self) -> bool;
@@ -221,7 +223,11 @@ impl<T: EventListener> Execute<T> for Action {
ctx.cancel_search();
ctx.start_search(direction);
},
- Action::SearchAction(SearchAction::SearchDeleteWord) => ctx.pop_word_search(),
+ Action::SearchAction(SearchAction::SearchDeleteWord) => ctx.search_pop_word(),
+ Action::SearchAction(SearchAction::SearchHistoryPrevious) => {
+ ctx.search_history_previous()
+ },
+ Action::SearchAction(SearchAction::SearchHistoryNext) => ctx.search_history_next(),
Action::SearchForward => ctx.start_search(Direction::Right),
Action::SearchBackward => ctx.start_search(Direction::Left),
Action::Copy => ctx.copy_selection(ClipboardType::Clipboard),
@@ -1117,7 +1123,11 @@ mod tests {
fn search_input(&mut self, _c: char) {}
- fn pop_word_search(&mut self) {}
+ fn search_pop_word(&mut self) {}
+
+ fn search_history_previous(&mut self) {}
+
+ fn search_history_next(&mut self) {}
fn advance_search_origin(&mut self, _direction: Direction) {}