Skip to content

Commit

Permalink
Fix surround_replace replacing the wrong character on the right. (#571)
Browse files Browse the repository at this point in the history
Fixes #569.
  • Loading branch information
cessen authored Aug 11, 2021
1 parent 27b551d commit dde2be9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4017,11 +4017,11 @@ fn surround_replace(cx: &mut Context) {
let transaction = Transaction::change(
doc.text(),
change_pos.iter().enumerate().map(|(i, &pos)| {
if i % 2 == 0 {
(pos, pos + 1, Some(Tendril::from_char(open)))
} else {
(pos.saturating_sub(1), pos, Some(Tendril::from_char(close)))
}
(
pos,
pos + 1,
Some(Tendril::from_char(if i % 2 == 0 { open } else { close })),
)
}),
);
doc.apply(&transaction, view.id);
Expand Down

0 comments on commit dde2be9

Please # to comment.