aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorCharlie Groves2022-08-29 00:48:49 +0000
committerGitHub2022-08-29 00:48:49 +0000
commitf38ede8631b083c1c74d31b7658ad162d31c3972 (patch)
tree58e93b5bf7a330b9d60a2c1c5a52d67fcd32971f /helix-term/src/ui/editor.rs
parent51b62230da81913564692482d8f365e27d6f6cec (diff)
Add bracketed paste (#3233)
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs23
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