diff options
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r-- | helix-term/src/ui/editor.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 60cab905..7326b70d 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -936,7 +936,7 @@ impl EditorView { impl EditorView { fn handle_mouse_event( &mut self, - event: MouseEvent, + event: &MouseEvent, cxt: &mut commands::Context, ) -> EventResult { let config = cxt.editor.config(); @@ -946,7 +946,7 @@ impl EditorView { column, modifiers, .. - } = event; + } = *event; let pos_and_view = |editor: &Editor, row, column| { editor.tree.views().find_map(|(view, _focus)| { @@ -1115,7 +1115,7 @@ impl EditorView { impl Component for EditorView { fn handle_event( &mut self, - event: Event, + event: &Event, context: &mut crate::compositor::Context, ) -> EventResult { let mut cx = commands::Context { @@ -1128,6 +1128,23 @@ impl Component for EditorView { }; match event { + Event::Paste(contents) => { + cx.count = cx.editor.count; + commands::paste_bracketed_value(&mut cx, contents.clone()); + cx.editor.count = None; + + let config = cx.editor.config(); + let (view, doc) = current!(cx.editor); + view.ensure_cursor_in_view(doc, config.scrolloff); + + // Store a history state if not in insert mode. Otherwise wait till we exit insert + // to include any edits to the paste in the history state. + if doc.mode() != Mode::Insert { + doc.append_changes_to_history(view.id); + } + + EventResult::Consumed(None) + } Event::Resize(_width, _height) => { // Ignore this event, we handle resizing just before rendering to screen. // Handling it here but not re-rendering will cause flashing |