aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/event.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-07-25 14:05:11 +0000
committerGitHub <noreply@github.com>2020-07-25 14:05:11 +0000
commit9a4d847d897016ac3f1662fec45d372b879072cd (patch)
tree7d22cae88c54275bd0dda39b64b78e8b8d0e91e0 /alacritty/src/event.rs
parent555a85ed95008f023b8f23859dff1841d934cd36 (diff)
downloadr-alacritty-9a4d847d897016ac3f1662fec45d372b879072cd.tar.gz
r-alacritty-9a4d847d897016ac3f1662fec45d372b879072cd.tar.bz2
r-alacritty-9a4d847d897016ac3f1662fec45d372b879072cd.zip
Fix viless search origin
When searching without vi mode the display is no longer reset when the user hasn't jumped between matches at all. Since there's no reason to confirm the search, we shouldn't just reset the viewport without a good reason. The search is now also restarted completely when the entire search regex is deleted. While this doesn't reset to the original viewport position if the user has jumped between matches, it should make things feel a little less arbitrary. Fixes #4020.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r--alacritty/src/event.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 56e5b841..84af666a 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -396,8 +396,10 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
fn cancel_search(&mut self) {
self.terminal.cancel_search();
- // Recover pre-search state.
- self.search_reset_state();
+ // Recover pre-search state in vi mode.
+ if self.terminal.mode().contains(TermMode::VI) {
+ self.search_reset_state();
+ }
// Move vi cursor down if resize will pull from history.
if self.terminal.history_size() != 0 && self.terminal.grid().display_offset() == 0 {
@@ -513,6 +515,11 @@ impl<'a, N: Notify + 'a, T: EventListener> ActionContext<'a, N, T> {
// Stop search if there's nothing to search for.
self.search_reset_state();
self.terminal.cancel_search();
+
+ // Restart search without vi mode to clear the search origin.
+ if !self.terminal.mode().contains(TermMode::VI) {
+ self.start_search(self.search_state.direction);
+ }
} else {
// Create terminal search from the new regex string.
self.terminal.start_search(&regex);