aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-24 00:52:45 +0000
committerNathan Vegdahl2021-07-24 00:52:45 +0000
commit8f43dc40398ff8372b1612241081926bac6d2055 (patch)
treee2a5e04b5ca8c4f9661dfe41858f09ad1b580883 /helix-term
parent43594049ddd6b0ec3794807016ab3cd2a6a38834 (diff)
Fix surround replace command replacing the wrong position on the right.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 57df47a7..ca977f80 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -3738,8 +3738,11 @@ fn surround_replace(cx: &mut Context) {
let transaction = Transaction::change(
doc.text(),
change_pos.iter().enumerate().map(|(i, &pos)| {
- let ch = if i % 2 == 0 { open } else { close };
- (pos, pos + 1, Some(Tendril::from_char(ch)))
+ if i % 2 == 0 {
+ (pos, pos + 1, Some(Tendril::from_char(open)))
+ } else {
+ (pos.saturating_sub(1), pos, Some(Tendril::from_char(close)))
+ }
}),
);
doc.apply(&transaction, view.id);