diff options
author | Nathan Vegdahl | 2021-07-01 16:51:24 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-07-01 21:22:28 +0000 |
commit | e725957704274b1ec814a34ddf6f75faf35358e7 (patch) | |
tree | 58bc8a2a96bf8839bcac1ca7d00b5b769e139ba7 /helix-core/src/selection.rs | |
parent | 7c7be6d58326725954be7bd16fa3ff5e84610c17 (diff) |
Ensure a minimum selection width on commands that need it.
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r-- | helix-core/src/selection.rs | 9 |
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 { |