@@ -913,6 +913,7 @@ fn replace_selections_with_clipboard_impl(
913 cx: &mut compositor::Context,
913 cx: &mut compositor::Context,
914 clipboard_type: ClipboardType,
914 clipboard_type: ClipboardType,
915) -> anyhow::Result<()> {
915) -> anyhow::Result<()> {
916+ let scrolloff = cx.editor.config().scrolloff;
916 let (view, doc) = current!(cx.editor);
917 let (view, doc) = current!(cx.editor);
918 match cx.editor.clipboard_provider.get_contents(clipboard_type) {
919 match cx.editor.clipboard_provider.get_contents(clipboard_type) {
@@ -924,6 +925,7 @@ fn replace_selections_with_clipboard_impl(
925 doc.apply(&transaction, view.id);
926 doc.apply(&transaction, view.id);
926 doc.append_changes_to_history(view);
927 doc.append_changes_to_history(view);
928+ view.ensure_cursor_in_view(doc, scrolloff);
929 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
931 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
@@ -1570,6 +1572,7 @@ fn sort_impl(
1570 _args: &[Cow<str>],
1572 _args: &[Cow<str>],
1571 reverse: bool,
1573 reverse: bool,
1572) -> anyhow::Result<()> {
1574) -> anyhow::Result<()> {
1575+ let scrolloff = cx.editor.config().scrolloff;
1573 let (view, doc) = current!(cx.editor);
1576 let (view, doc) = current!(cx.editor);
1574 let text = doc.text().slice(..);
1577 let text = doc.text().slice(..);
@@ -1595,6 +1598,7 @@ fn sort_impl(
1596 doc.apply(&transaction, view.id);
1599 doc.apply(&transaction, view.id);
1597 doc.append_changes_to_history(view);
1600 doc.append_changes_to_history(view);
1601+ view.ensure_cursor_in_view(doc, scrolloff);