aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorPascal Kuthe2023-11-30 23:00:16 +0000
committerBlaž Hrastnik2024-03-23 06:35:25 +0000
commit66b9ff1d2a9ad9ed0ec3e0416934437cfd1ab01f (patch)
tree9916b619b6eb42cd617f5e5eaa4095c349537f90 /helix-term
parent69e07ab61e51598ba6e31bdd79608091fdbba254 (diff)
dismiss pending keys properly for mouse/paste
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index c1e36bbd..ad7aa5c5 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1048,13 +1048,33 @@ impl EditorView {
}
impl EditorView {
+ /// must be called whenever the editor processed input that
+ /// is not a `KeyEvent`. In these cases any pending keys/on next
+ /// key callbacks must be canceled.
+ fn handle_non_key_input(&mut self, cxt: &mut commands::Context) {
+ cxt.editor.status_msg = None;
+ cxt.editor.reset_idle_timer();
+ // HACKS: create a fake key event that will never trigger any actual map
+ // and therefore simply acts as "dismiss"
+ let null_key_event = KeyEvent {
+ code: KeyCode::Null,
+ modifiers: KeyModifiers::empty(),
+ };
+ // dismiss any pending keys
+ if let Some(on_next_key) = self.on_next_key.take() {
+ on_next_key(cxt, null_key_event);
+ }
+ self.handle_keymap_event(cxt.editor.mode, cxt, null_key_event);
+ self.pseudo_pending.clear();
+ }
+
fn handle_mouse_event(
&mut self,
event: &MouseEvent,
cxt: &mut commands::Context,
) -> EventResult {
if event.kind != MouseEventKind::Moved {
- cxt.editor.reset_idle_timer();
+ self.handle_non_key_input(cxt)
}
let config = cxt.editor.config();
@@ -1279,6 +1299,7 @@ impl Component for EditorView {
match event {
Event::Paste(contents) => {
+ self.handle_non_key_input(&mut cx);
cx.count = cx.editor.count;
commands::paste_bracketed_value(&mut cx, contents.clone());
cx.editor.count = None;