aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/textobject.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src/textobject.rs')
-rw-r--r--helix-core/src/textobject.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/helix-core/src/textobject.rs b/helix-core/src/textobject.rs
index 76c6d103..972a80e7 100644
--- a/helix-core/src/textobject.rs
+++ b/helix-core/src/textobject.rs
@@ -231,8 +231,20 @@ fn textobject_pair_surround_impl(
};
pair_pos
.map(|(anchor, head)| match textobject {
- TextObject::Inside => Range::new(next_grapheme_boundary(slice, anchor), head),
- TextObject::Around => Range::new(anchor, next_grapheme_boundary(slice, head)),
+ TextObject::Inside => {
+ if anchor < head {
+ Range::new(next_grapheme_boundary(slice, anchor), head)
+ } else {
+ Range::new(anchor, next_grapheme_boundary(slice, head))
+ }
+ }
+ TextObject::Around => {
+ if anchor < head {
+ Range::new(anchor, next_grapheme_boundary(slice, head))
+ } else {
+ Range::new(next_grapheme_boundary(slice, anchor), head)
+ }
+ }
TextObject::Movement => unreachable!(),
})
.unwrap_or(range)