mirror of https://github.com/helix-editor/helix
Extract a common function for paste_before/_after
parent
376d99a51d
commit
737282d0e9
|
@ -4682,7 +4682,7 @@ 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.editor, ClipboardType::Selection, cx.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paste_after(cx: &mut Context) {
|
fn paste(cx: &mut Context, pos: Paste) {
|
||||||
let count = cx.count();
|
let count = cx.count();
|
||||||
let reg_name = cx.register.unwrap_or('"');
|
let reg_name = cx.register.unwrap_or('"');
|
||||||
let (view, doc) = current!(cx.editor);
|
let (view, doc) = current!(cx.editor);
|
||||||
|
@ -4690,24 +4690,18 @@ fn paste_after(cx: &mut Context) {
|
||||||
|
|
||||||
if let Some(transaction) = registers
|
if let Some(transaction) = registers
|
||||||
.read(reg_name)
|
.read(reg_name)
|
||||||
.and_then(|values| paste_impl(values, doc, view, Paste::After, count))
|
.and_then(|values| paste_impl(values, doc, view, pos, count))
|
||||||
{
|
{
|
||||||
doc.apply(&transaction, view.id);
|
doc.apply(&transaction, view.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paste_before(cx: &mut Context) {
|
fn paste_after(cx: &mut Context) {
|
||||||
let count = cx.count();
|
paste(cx, Paste::After)
|
||||||
let reg_name = cx.register.unwrap_or('"');
|
}
|
||||||
let (view, doc) = current!(cx.editor);
|
|
||||||
let registers = &mut cx.editor.registers;
|
|
||||||
|
|
||||||
if let Some(transaction) = registers
|
fn paste_before(cx: &mut Context) {
|
||||||
.read(reg_name)
|
paste(cx, Paste::Before)
|
||||||
.and_then(|values| paste_impl(values, doc, view, Paste::Before, count))
|
|
||||||
{
|
|
||||||
doc.apply(&transaction, view.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_lines(doc: &Document, view_id: ViewId) -> Vec<usize> {
|
fn get_lines(doc: &Document, view_id: ViewId) -> Vec<usize> {
|
||||||
|
|
Loading…
Reference in New Issue