@@ -913,6 +913,7 @@ fn replace_selections_with_clipboard_impl(
913913 cx: &mut compositor::Context,
914914 clipboard_type: ClipboardType,
915915) -> anyhow::Result<()> {
916+ let scrolloff = cx.editor.config().scrolloff;
916917 let (view, doc) = current!(cx.editor);
917918
918919 match cx.editor.clipboard_provider.get_contents(clipboard_type) {
@@ -924,6 +925,7 @@ fn replace_selections_with_clipboard_impl(
924925
925926 doc.apply(&transaction, view.id);
926927 doc.append_changes_to_history(view);
928+ view.ensure_cursor_in_view(doc, scrolloff);
927929 Ok(())
928930 }
929931 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
@@ -1570,6 +1572,7 @@ fn sort_impl(
15701572 _args: &[Cow<str>],
15711573 reverse: bool,
15721574) -> anyhow::Result<()> {
1575+ let scrolloff = cx.editor.config().scrolloff;
15731576 let (view, doc) = current!(cx.editor);
15741577 let text = doc.text().slice(..);
15751578
@@ -1595,6 +1598,7 @@ fn sort_impl(
15951598
15961599 doc.apply(&transaction, view.id);
15971600 doc.append_changes_to_history(view);
1601+ view.ensure_cursor_in_view(doc, scrolloff);
15981602
15991603 Ok(())
16001604}