|
|
@ -1304,6 +1304,7 @@ fn replace(cx: &mut Context) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
apply_transaction(&transaction, doc, view);
|
|
|
|
apply_transaction(&transaction, doc, view);
|
|
|
|
|
|
|
|
exit_select_mode(cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3581,18 +3582,19 @@ fn replace_with_yanked(cx: &mut Context) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
apply_transaction(&transaction, doc, view);
|
|
|
|
apply_transaction(&transaction, doc, view);
|
|
|
|
|
|
|
|
exit_select_mode(cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn replace_selections_with_clipboard_impl(
|
|
|
|
fn replace_selections_with_clipboard_impl(
|
|
|
|
editor: &mut Editor,
|
|
|
|
cx: &mut Context,
|
|
|
|
clipboard_type: ClipboardType,
|
|
|
|
clipboard_type: ClipboardType,
|
|
|
|
count: usize,
|
|
|
|
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
let (view, doc) = current!(editor);
|
|
|
|
let count = cx.count();
|
|
|
|
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
|
|
|
|
|
|
|
|
match editor.clipboard_provider.get_contents(clipboard_type) {
|
|
|
|
match cx.editor.clipboard_provider.get_contents(clipboard_type) {
|
|
|
|
Ok(contents) => {
|
|
|
|
Ok(contents) => {
|
|
|
|
let selection = doc.selection(view.id);
|
|
|
|
let selection = doc.selection(view.id);
|
|
|
|
let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
|
|
|
|
let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
|
|
|
@ -3605,18 +3607,20 @@ fn replace_selections_with_clipboard_impl(
|
|
|
|
|
|
|
|
|
|
|
|
apply_transaction(&transaction, doc, view);
|
|
|
|
apply_transaction(&transaction, doc, view);
|
|
|
|
doc.append_changes_to_history(view.id);
|
|
|
|
doc.append_changes_to_history(view.id);
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(e) => Err(e.context("Couldn't get system clipboard contents")),
|
|
|
|
Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exit_select_mode(cx);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn replace_selections_with_clipboard(cx: &mut Context) {
|
|
|
|
fn replace_selections_with_clipboard(cx: &mut Context) {
|
|
|
|
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Clipboard, cx.count());
|
|
|
|
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Clipboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn replace_selections_with_primary_clipboard(cx: &mut Context) {
|
|
|
|
fn replace_selections_with_primary_clipboard(cx: &mut Context) {
|
|
|
|
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Selection, cx.count());
|
|
|
|
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Selection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn paste(cx: &mut Context, pos: Paste) {
|
|
|
|
fn paste(cx: &mut Context, pos: Paste) {
|
|
|
|