summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-08-11 00:17:59 +0000
committerGitHub2021-08-11 00:17:59 +0000
commitdde2be93956f82622c85171bd03dab1b6864318c (patch)
treec6b5f2d3a566ab7ffc8a183fb293d5e43bba1823 /helix-term/src/commands.rs
parent27b551d34593cd94a3fba016c3a7f2042f9d9d38 (diff)
Fix surround_replace replacing the wrong character on the right. (#571)
Fixes #569.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index b918256e..e15332c8 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -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);