@@ -3738,8 +3738,11 @@ fn surround_replace(cx: &mut Context) {
3738 let transaction = Transaction::change(
3738 let transaction = Transaction::change(
3739 doc.text(),
3739 doc.text(),
3740 change_pos.iter().enumerate().map(|(i, &pos)| {
3740 change_pos.iter().enumerate().map(|(i, &pos)| {
3741− let ch = if i % 2 == 0 { open } else { close };
3741+ if i % 2 == 0 {
3742− (pos, pos + 1, Some(Tendril::from_char(ch)))
3742+ (pos, pos + 1, Some(Tendril::from_char(open)))
3744+ (pos.saturating_sub(1), pos, Some(Tendril::from_char(close)))
3745 doc.apply(&transaction, view.id);
3748 doc.apply(&transaction, view.id);