fixed lag when S on empty
All checks were successful
Version Check / check-version (pull_request) Successful in 2s
All checks were successful
Version Check / check-version (pull_request) Successful in 2s
This commit is contained in:
@@ -124,6 +124,9 @@ where
|
|||||||
if !key_str.is_empty() {
|
if !key_str.is_empty() {
|
||||||
self.key_sequence.push_str(&key_str);
|
self.key_sequence.push_str(&key_str);
|
||||||
|
|
||||||
|
let mut exact_match = None;
|
||||||
|
let mut prefix_match = false;
|
||||||
|
|
||||||
// Collect all configured keybinds
|
// Collect all configured keybinds
|
||||||
let binds = [
|
let binds = [
|
||||||
(&self.config.keybinds.down, "down"),
|
(&self.config.keybinds.down, "down"),
|
||||||
@@ -131,6 +134,7 @@ where
|
|||||||
(&self.config.keybinds.edit, "edit"),
|
(&self.config.keybinds.edit, "edit"),
|
||||||
(&self.config.keybinds.edit_append, "edit_append"),
|
(&self.config.keybinds.edit_append, "edit_append"),
|
||||||
(&self.config.keybinds.edit_substitute, "edit_substitute"),
|
(&self.config.keybinds.edit_substitute, "edit_substitute"),
|
||||||
|
(&"S".to_string(), "edit_substitute"),
|
||||||
(&self.config.keybinds.search, "search"),
|
(&self.config.keybinds.search, "search"),
|
||||||
(&self.config.keybinds.next_match, "next_match"),
|
(&self.config.keybinds.next_match, "next_match"),
|
||||||
(&self.config.keybinds.previous_match, "previous_match"),
|
(&self.config.keybinds.previous_match, "previous_match"),
|
||||||
@@ -150,8 +154,19 @@ where
|
|||||||
(&"q".to_string(), "quit"),
|
(&"q".to_string(), "quit"),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut exact_match = None;
|
for (bind, action) in binds.iter() {
|
||||||
let mut prefix_match = false;
|
if bind == &&self.key_sequence {
|
||||||
|
exact_match = Some(*action);
|
||||||
|
break;
|
||||||
|
} else if bind.starts_with(&self.key_sequence) {
|
||||||
|
prefix_match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if exact_match.is_none() && !prefix_match {
|
||||||
|
// Not a match and not a prefix, restart with current key
|
||||||
|
self.key_sequence.clear();
|
||||||
|
self.key_sequence.push_str(&key_str);
|
||||||
|
|
||||||
for (bind, action) in binds.iter() {
|
for (bind, action) in binds.iter() {
|
||||||
if bind == &&self.key_sequence {
|
if bind == &&self.key_sequence {
|
||||||
@@ -161,6 +176,7 @@ where
|
|||||||
prefix_match = true;
|
prefix_match = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(action) = exact_match {
|
if let Some(action) = exact_match {
|
||||||
self.key_sequence.clear();
|
self.key_sequence.clear();
|
||||||
@@ -203,7 +219,6 @@ where
|
|||||||
}
|
}
|
||||||
} else if !prefix_match {
|
} else if !prefix_match {
|
||||||
self.key_sequence.clear();
|
self.key_sequence.clear();
|
||||||
self.key_sequence.push_str(&key_str);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Non-character keys reset the sequence buffer
|
// Non-character keys reset the sequence buffer
|
||||||
|
|||||||
Reference in New Issue
Block a user