aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/surround.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src/surround.rs')
-rw-r--r--helix-core/src/surround.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/helix-core/src/surround.rs b/helix-core/src/surround.rs
index b96cce5a..513f8749 100644
--- a/helix-core/src/surround.rs
+++ b/helix-core/src/surround.rs
@@ -260,7 +260,8 @@ pub fn get_surround_pos(
if change_pos.contains(&open_pos) || change_pos.contains(&close_pos) {
return Err(Error::CursorOverlap);
}
- change_pos.extend_from_slice(&[open_pos, close_pos]);
+ // ensure the positions are always paired in the forward direction
+ change_pos.extend_from_slice(&[open_pos.min(close_pos), close_pos.max(open_pos)]);
}
Ok(change_pos)
}