on master help sign in
Fix surround replace command replacing the wrong position on the right.
8f43dc4Nathan Vegdahl
helix-term/src/commands.rs+5−2
@@ -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)))
3743+ } else {
3744+ (pos.saturating_sub(1), pos, Some(Tendril::from_char(close)))
3745+ }
3743 }),
3746 }),
3744 );
3747 );
3745 doc.apply(&transaction, view.id);
3748 doc.apply(&transaction, view.id);