diff options
author | Bram | 2022-02-23 03:46:12 +0000 |
---|---|---|
committer | GitHub | 2022-02-23 03:46:12 +0000 |
commit | 40eb1268c72b60f1249389c58892e7c45d268cff (patch) | |
tree | 84f741c7067547b4af3e6b0a867c10639d00ede8 /helix-term/src/ui/editor.rs | |
parent | e1a92fd3998aca2a313d4cbf0aca3157eca0b53f (diff) |
Close some popups automatically (#1285)
* Add Event::Used to use event callback without consuming
* Close popup if contents ignored event
* collect event results before executing callbacks
* don't add new result variant, use Ignored(..) instead
* break in match cases
* Make auto_close configurable
* fix merge
* auto close hover popups
* fix formatting
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r-- | helix-term/src/ui/editor.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index fc749ebb..29552b67 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -872,9 +872,7 @@ impl EditorView { let path = match doc.path() { Some(path) => path.clone(), - None => { - return EventResult::Ignored; - } + None => return EventResult::Ignored(None), }; let line = coords.row + view.offset.row; @@ -884,7 +882,7 @@ impl EditorView { } } - EventResult::Ignored + EventResult::Ignored(None) } MouseEvent { @@ -897,7 +895,7 @@ impl EditorView { let pos = match view.pos_at_screen_coords(doc, row, column) { Some(pos) => pos, - None => return EventResult::Ignored, + None => return EventResult::Ignored(None), }; let mut selection = doc.selection(view.id).clone(); @@ -928,7 +926,7 @@ impl EditorView { match result { Some(view_id) => cxt.editor.tree.focus = view_id, - None => return EventResult::Ignored, + None => return EventResult::Ignored(None), } let offset = cxt.editor.config.scroll_lines.abs() as usize; @@ -944,14 +942,14 @@ impl EditorView { .. } => { if !cxt.editor.config.middle_click_paste { - return EventResult::Ignored; + return EventResult::Ignored(None); } let (view, doc) = current!(cxt.editor); let range = doc.selection(view.id).primary(); if range.to() - range.from() <= 1 { - return EventResult::Ignored; + return EventResult::Ignored(None); } commands::MappableCommand::yank_main_selection_to_primary_clipboard.execute(cxt); @@ -988,7 +986,7 @@ impl EditorView { return EventResult::Consumed(None); } } - EventResult::Ignored + EventResult::Ignored(None) } MouseEvent { @@ -1000,7 +998,7 @@ impl EditorView { } => { let editor = &mut cxt.editor; if !editor.config.middle_click_paste { - return EventResult::Ignored; + return EventResult::Ignored(None); } if modifiers == crossterm::event::KeyModifiers::ALT { @@ -1023,10 +1021,10 @@ impl EditorView { return EventResult::Consumed(None); } - EventResult::Ignored + EventResult::Ignored(None) } - _ => EventResult::Ignored, + _ => EventResult::Ignored(None), } } } @@ -1117,7 +1115,7 @@ impl Component for EditorView { // if the command consumed the last view, skip the render. // on the next loop cycle the Application will then terminate. if cx.editor.should_close() { - return EventResult::Ignored; + return EventResult::Ignored(None); } let (view, doc) = current!(cx.editor); |