@@ -3467,7 +3467,14 @@ enum Paste {
34673467 Cursor,
34683468}
34693469
3470−fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Paste, count: usize) {
3470+fn paste_impl(
3471+ values: &[String],
3472+ doc: &mut Document,
3473+ view: &mut View,
3474+ action: Paste,
3475+ count: usize,
3476+ mode: Mode,
3477+) {
34713478 if values.is_empty() {
34723479 return;
34733480 }
@@ -3499,7 +3506,7 @@ fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Pa
34993506 let mut offset = 0;
35003507 let mut ranges = SmallVec::with_capacity(selection.len());
35013508
3502− let transaction = Transaction::change_by_selection(text, selection, |range| {
3509+ let mut transaction = Transaction::change_by_selection(text, selection, |range| {
35033510 let pos = match (action, linewise) {
35043511 // paste linewise before
35053512 (Paste::Before, true) => text.line_to_char(text.char_to_line(range.from())),
@@ -3531,7 +3538,9 @@ fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Pa
35313538 (pos, pos, value)
35323539 });
35333540
3534− let transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
3541+ if mode == Mode::Normal {
3542+ transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
3543+ }
35353544
35363545 apply_transaction(&transaction, doc, view);
35373546}
@@ -3543,7 +3552,7 @@ pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) {
35433552 Mode::Normal => Paste::Before,
35443553 };
35453554 let (view, doc) = current!(cx.editor);
3546− paste_impl(&[contents], doc, view, paste, count);
3555+ paste_impl(&[contents], doc, view, paste, count, cx.editor.mode);
35473556}
35483557
35493558fn paste_clipboard_impl(
@@ -3555,7 +3564,7 @@ fn paste_clipboard_impl(
35553564 let (view, doc) = current!(editor);
35563565 match editor.clipboard_provider.get_contents(clipboard_type) {
35573566 Ok(contents) => {
3558− paste_impl(&[contents], doc, view, action, count);
3567+ paste_impl(&[contents], doc, view, action, count, editor.mode);
35593568 Ok(())
35603569 }
35613570 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
@@ -3674,7 +3683,7 @@ fn paste(cx: &mut Context, pos: Paste) {
36743683 let registers = &mut cx.editor.registers;
36753684
36763685 if let Some(values) = registers.read(reg_name) {
3677− paste_impl(values, doc, view, pos, count);
3686+ paste_impl(values, doc, view, pos, count, cx.editor.mode);
36783687 }
36793688}
36803689