From e725957704274b1ec814a34ddf6f75faf35358e7 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Thu, 1 Jul 2021 09:51:24 -0700 Subject: Ensure a minimum selection width on commands that need it. --- helix-core/src/selection.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'helix-core') 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> + 'a { -- cgit v1.2.3-70-g09d2