aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/object.rs2
-rw-r--r--helix-core/src/selection.rs25
2 files changed, 5 insertions, 22 deletions
diff --git a/helix-core/src/object.rs b/helix-core/src/object.rs
index 863b6e55..950b7592 100644
--- a/helix-core/src/object.rs
+++ b/helix-core/src/object.rs
@@ -6,7 +6,7 @@ use smallvec::smallvec;
pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: &Selection) -> Selection {
let tree = syntax.tree();
- selection.clone().transformed(|range| {
+ selection.clone().transform(|range| {
let from = text.char_to_byte(range.from());
let to = text.char_to_byte(range.to());
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index ebc88f8b..f3119a59 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -261,7 +261,7 @@ impl Selection {
pub fn push(mut self, range: Range) -> Self {
self.ranges.push(range);
- self.normalized()
+ self.normalize()
}
// replace_range
@@ -308,7 +308,7 @@ impl Selection {
}
/// Normalizes a `Selection`.
- pub fn normalize(&mut self) -> &mut Self {
+ pub fn normalize(mut self) -> Self {
let primary = self.ranges[self.primary_index];
self.ranges.sort_unstable_by_key(Range::from);
self.primary_index = self
@@ -335,13 +335,6 @@ impl Selection {
self
}
- /// Normalizes a `Selection`.
- #[must_use]
- pub fn normalized(mut self) -> Self {
- self.normalize();
- self
- }
-
// TODO: consume an iterator or a vec to reduce allocations?
#[must_use]
pub fn new(ranges: SmallVec<[Range; 1]>, primary_index: usize) -> Self {
@@ -355,14 +348,14 @@ impl Selection {
if selection.ranges.len() > 1 {
// TODO: only normalize if needed (any ranges out of order)
- selection.normalize();
+ selection = selection.normalize();
}
selection
}
/// Takes a closure and maps each `Range` over the closure.
- pub fn transform<F>(&mut self, f: F) -> &mut Self
+ pub fn transform<F>(mut self, f: F) -> Self
where
F: Fn(Range) -> Range,
{
@@ -373,16 +366,6 @@ impl Selection {
self
}
- /// Takes a closure and maps each `Range` over the closure.
- #[must_use]
- pub fn transformed<F>(mut self, f: F) -> Self
- where
- F: Fn(Range) -> Range,
- {
- self.transform(f);
- self
- }
-
pub fn fragments<'a>(&'a self, text: RopeSlice<'a>) -> impl Iterator<Item = Cow<str>> + 'a {
self.ranges.iter().map(move |range| range.fragment(text))
}