mirror of https://github.com/helix-editor/helix
Fix surround replace command replacing the wrong position on the right.
parent
43594049dd
commit
8f43dc4039
|
@ -3738,8 +3738,11 @@ fn surround_replace(cx: &mut Context) {
|
||||||
let transaction = Transaction::change(
|
let transaction = Transaction::change(
|
||||||
doc.text(),
|
doc.text(),
|
||||||
change_pos.iter().enumerate().map(|(i, &pos)| {
|
change_pos.iter().enumerate().map(|(i, &pos)| {
|
||||||
let ch = if i % 2 == 0 { open } else { close };
|
if i % 2 == 0 {
|
||||||
(pos, pos + 1, Some(Tendril::from_char(ch)))
|
(pos, pos + 1, Some(Tendril::from_char(open)))
|
||||||
|
} else {
|
||||||
|
(pos.saturating_sub(1), pos, Some(Tendril::from_char(close)))
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
doc.apply(&transaction, view.id);
|
doc.apply(&transaction, view.id);
|
||||||
|
|
Loading…
Reference in New Issue