From 350535208f134f1d8a6201833ad560905fea5abc Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Thu, 2 Feb 2023 20:56:52 +0100 Subject: [PATCH] always commit to history when pasting (#5790) --- helix-term/src/commands.rs | 1 + helix-term/src/commands/typed.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 7d5f22415..d1dc92236 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3746,6 +3746,7 @@ fn paste_impl( } doc.apply(&transaction, view.id); + doc.append_changes_to_history(view); } pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) { diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index ec7100a63..f2495d8ce 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -913,6 +913,7 @@ fn replace_selections_with_clipboard_impl( cx: &mut compositor::Context, clipboard_type: ClipboardType, ) -> anyhow::Result<()> { + let scrolloff = cx.editor.config().scrolloff; let (view, doc) = current!(cx.editor); match cx.editor.clipboard_provider.get_contents(clipboard_type) { @@ -924,6 +925,7 @@ fn replace_selections_with_clipboard_impl( doc.apply(&transaction, view.id); doc.append_changes_to_history(view); + view.ensure_cursor_in_view(doc, scrolloff); Ok(()) } Err(e) => Err(e.context("Couldn't get system clipboard contents")), @@ -1570,6 +1572,7 @@ fn sort_impl( _args: &[Cow], reverse: bool, ) -> anyhow::Result<()> { + let scrolloff = cx.editor.config().scrolloff; let (view, doc) = current!(cx.editor); let text = doc.text().slice(..); @@ -1595,6 +1598,7 @@ fn sort_impl( doc.apply(&transaction, view.id); doc.append_changes_to_history(view); + view.ensure_cursor_in_view(doc, scrolloff); Ok(()) }