aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r--helix-core/src/selection.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index f3119a59..e9dea518 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -308,7 +308,7 @@ impl Selection {
}
/// Normalizes a `Selection`.
- pub fn normalize(mut self) -> Self {
+ fn normalize(mut self) -> Self {
let primary = self.ranges[self.primary_index];
self.ranges.sort_unstable_by_key(Range::from);
self.primary_index = self
@@ -363,7 +363,12 @@ impl Selection {
*range = f(*range)
}
- self
+ self.normalize()
+ }
+
+ /// A convenience short-cut for `transform(|r| r.min_width_1(text))`.
+ pub fn min_width_1(mut self, text: RopeSlice) -> Self {
+ self.transform(|r| r.min_width_1(text))
}
pub fn fragments<'a>(&'a self, text: RopeSlice<'a>) -> impl Iterator<Item = Cow<str>> + 'a {