Fix surround_replace replacing the wrong character on the right. (#571)

Fixes #569.
This commit is contained in:
Nathan Vegdahl 2021-08-10 17:17:59 -07:00 committed by GitHub
parent 27b551d345
commit dde2be9395
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);