@@ -3369,13 +3369,7 @@ enum Paste {
33693369 Cursor,
33703370}
33713371
3372−fn paste_impl(
3373− values: &[String],
3374− doc: &mut Document,
3375− view: &View,
3376− action: Paste,
3377− count: usize,
3378−) -> Option<Transaction> {
3372+fn paste_impl(values: &[String], doc: &mut Document, view: &View, action: Paste, count: usize) {
33793373 let repeat = std::iter::repeat(
33803374 values
33813375 .last()
@@ -3418,8 +3412,17 @@ fn paste_impl(
34183412 };
34193413 (pos, pos, values.next())
34203414 });
3415+ doc.apply(&transaction, view.id);
3416+}
34213417
3422− Some(transaction)
3418+pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) {
3419+ let count = cx.count();
3420+ let (view, doc) = current!(cx.editor);
3421+ let paste = match doc.mode {
3422+ Mode::Insert | Mode::Select => Paste::Cursor,
3423+ Mode::Normal => Paste::Before,
3424+ };
3425+ paste_impl(&[contents], doc, view, paste, count);
34233426}
34243427
34253428fn paste_clipboard_impl(
@@ -3429,18 +3432,11 @@ fn paste_clipboard_impl(
34293432 count: usize,
34303433) -> anyhow::Result<()> {
34313434 let (view, doc) = current!(editor);
3432−
3433− match editor
3434− .clipboard_provider
3435− .get_contents(clipboard_type)
3436− .map(|contents| paste_impl(&[contents], doc, view, action, count))
3437− {
3438− Ok(Some(transaction)) => {
3439− doc.apply(&transaction, view.id);
3440− doc.append_changes_to_history(view.id);
3435+ match editor.clipboard_provider.get_contents(clipboard_type) {
3436+ Ok(contents) => {
3437+ paste_impl(&[contents], doc, view, action, count);
34413438 Ok(())
34423439 }
3443− Ok(None) => Ok(()),
34443440 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
34453441 }
34463442}
@@ -3553,11 +3549,8 @@ fn paste(cx: &mut Context, pos: Paste) {
35533549 let (view, doc) = current!(cx.editor);
35543550 let registers = &mut cx.editor.registers;
35553551
3556− if let Some(transaction) = registers
3557− .read(reg_name)
3558− .and_then(|values| paste_impl(values, doc, view, pos, count))
3559− {
3560− doc.apply(&transaction, view.id);
3552+ if let Some(values) = registers.read(reg_name) {
3553+ paste_impl(values, doc, view, pos, count);
35613554 }
35623555}
35633556
@@ -4849,7 +4842,7 @@ fn replay_macro(cx: &mut Context) {
48494842 cx.callback = Some(Box::new(move |compositor, cx| {
48504843 for _ in 0..count {
48514844 for &key in keys.iter() {
4852− compositor.handle_event(compositor::Event::Key(key), cx);
4845+ compositor.handle_event(&compositor::Event::Key(key), cx);
48534846 }
48544847 }
48554848 // The macro under replay is cleared at the end of the callback, not in the