@@ -3369,13 +3369,7 @@ enum Paste {
3372−fn paste_impl(
3372+fn paste_impl(values: &[String], doc: &mut Document, view: &View, action: Paste, count: usize) {
3374− doc: &mut Document,
3378−) -> Option<Transaction> {
3379 let repeat = std::iter::repeat(
3373 let repeat = std::iter::repeat(
@@ -3418,8 +3412,17 @@ fn paste_impl(
3419 (pos, pos, values.next())
3413 (pos, pos, values.next())
3415+ doc.apply(&transaction, view.id);
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,
3425+ paste_impl(&[contents], doc, view, paste, count);
3425fn paste_clipboard_impl(
3428fn paste_clipboard_impl(
@@ -3429,18 +3432,11 @@ fn paste_clipboard_impl(
3429 count: usize,
3432 count: usize,
3430) -> anyhow::Result<()> {
3433) -> anyhow::Result<()> {
3431 let (view, doc) = current!(editor);
3434 let (view, doc) = current!(editor);
3434− .clipboard_provider
3435− .get_contents(clipboard_type)
3435+ match editor.clipboard_provider.get_contents(clipboard_type) {
3436− .map(|contents| paste_impl(&[contents], doc, view, action, count))
3437+ paste_impl(&[contents], doc, view, action, count);
3438− Ok(Some(transaction)) => {
3439− doc.apply(&transaction, view.id);
3440− doc.append_changes_to_history(view.id);
3443− Ok(None) => Ok(()),
3444 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
3440 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
@@ -3553,11 +3549,8 @@ fn paste(cx: &mut Context, pos: Paste) {
3553 let (view, doc) = current!(cx.editor);
3549 let (view, doc) = current!(cx.editor);
3554 let registers = &mut cx.editor.registers;
3550 let registers = &mut cx.editor.registers;
3556− if let Some(transaction) = registers
3552+ if let Some(values) = registers.read(reg_name) {
3558− .and_then(|values| paste_impl(values, doc, view, pos, count))
3553+ paste_impl(values, doc, view, pos, count);
3560− doc.apply(&transaction, view.id);
@@ -4849,7 +4842,7 @@ fn replay_macro(cx: &mut Context) {
4849 cx.callback = Some(Box::new(move |compositor, cx| {
4842 cx.callback = Some(Box::new(move |compositor, cx| {
4850 for _ in 0..count {
4843 for _ in 0..count {
4851 for &key in keys.iter() {
4844 for &key in keys.iter() {
4852− compositor.handle_event(compositor::Event::Key(key), cx);
4845+ compositor.handle_event(&compositor::Event::Key(key), cx);
4855 // The macro under replay is cleared at the end of the callback, not in the
4848 // The macro under replay is cleared at the end of the callback, not in the