on master help sign in
Fix surround_replace replacing the wrong character on the right. (#571)

Fixes #569.

commitdde2be93956f82622c85171bd03dab1b6864318c authorNathan Vegdahl <cessen@cessen.com> dateTue 10 Aug 2021, 17:17 (5 years ago) parent27b551d
1 file changed+5−5
helix-term/src/commands.rs+5−5
helix-term/src/commands.rs+5−5
@@ -4017,11 +4017,11 @@ fn surround_replace(cx: &mut Context) {
40174017 let transaction = Transaction::change(
40184018 doc.text(),
40194019 change_pos.iter().enumerate().map(|(i, &pos)| {
4020− if i % 2 == 0 {
4021− (pos, pos + 1, Some(Tendril::from_char(open)))
4022− } else {
4023− (pos.saturating_sub(1), pos, Some(Tendril::from_char(close)))
4024− }
4020+ (
4021+ pos,
4022+ pos + 1,
4023+ Some(Tendril::from_char(if i % 2 == 0 { open } else { close })),
4024+ )
40254025 }),
40264026 );
40274027 doc.apply(&transaction, view.id);