on master help sign in
Fix surround replace command replacing the wrong position on the right.
commit8f43dc40398ff8372b1612241081926bac6d2055 authorNathan Vegdahl <cessen@cessen.com> dateFri 23 Jul 2021, 17:52 (5 years ago) parent4359404
1 file changed+5−2
helix-term/src/commands.rs+5−2
helix-term/src/commands.rs+5−2
@@ -3738,8 +3738,11 @@ fn surround_replace(cx: &mut Context) {
37383738 let transaction = Transaction::change(
37393739 doc.text(),
37403740 change_pos.iter().enumerate().map(|(i, &pos)| {
3741− let ch = if i % 2 == 0 { open } else { close };
3742− (pos, pos + 1, Some(Tendril::from_char(ch)))
3741+ if i % 2 == 0 {
3742+ (pos, pos + 1, Some(Tendril::from_char(open)))
3743+ } else {
3744+ (pos.saturating_sub(1), pos, Some(Tendril::from_char(close)))
3745+ }
37433746 }),
37443747 );
37453748 doc.apply(&transaction, view.id);