summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-03 08:06:14 +0000
committerBlaž Hrastnik2022-03-03 08:06:14 +0000
commit737282d0e9d33923dad682994a521ac46be3c0d0 (patch)
tree00e1c267db2801a8eb9676c21c271531cbe5fc84 /helix-term/src/commands.rs
parent376d99a51d35c258182a088515285a99cc109073 (diff)
Extract a common function for paste_before/_after
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 4954c11a..936954c0 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -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());
}
-fn paste_after(cx: &mut Context) {
+fn paste(cx: &mut Context, pos: Paste) {
let count = cx.count();
let reg_name = cx.register.unwrap_or('"');
let (view, doc) = current!(cx.editor);
@@ -4690,24 +4690,18 @@ fn paste_after(cx: &mut Context) {
if let Some(transaction) = registers
.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);
}
}
-fn paste_before(cx: &mut Context) {
- let count = cx.count();
- let reg_name = cx.register.unwrap_or('"');
- let (view, doc) = current!(cx.editor);
- let registers = &mut cx.editor.registers;
+fn paste_after(cx: &mut Context) {
+ paste(cx, Paste::After)
+}
- if let Some(transaction) = registers
- .read(reg_name)
- .and_then(|values| paste_impl(values, doc, view, Paste::Before, count))
- {
- doc.apply(&transaction, view.id);
- }
+fn paste_before(cx: &mut Context) {
+ paste(cx, Paste::Before)
}
fn get_lines(doc: &Document, view_id: ViewId) -> Vec<usize> {