Skip to content

Commit 033ced4

Browse files
author
greg
committed
remove Range.shorten in favor of an inline solution
1 parent a8524b6 commit 033ced4

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

helix-core/src/increment/integer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a> IntegerIncrementor<'a> {
4646
// If there are trailing underscores, remove them from the range.
4747
// There is a `- 1` here because range ends are exclusive.
4848
while !range.is_empty() && text.char(range.to() - 1) == '_' {
49-
range = range.shorten()
49+
range = Range::new(range.from(), range.to() - 1)
5050
}
5151

5252
let word: String = text

helix-core/src/selection.rs

-18
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,6 @@ impl Range {
209209
}
210210
}
211211

212-
/// Shorten the range by 1 character.
213-
#[must_use]
214-
pub fn shorten(&self) -> Self {
215-
match self.head.cmp(&self.anchor) {
216-
std::cmp::Ordering::Greater => Self {
217-
anchor: self.anchor,
218-
head: self.head - 1,
219-
horiz: None,
220-
},
221-
std::cmp::Ordering::Less => Self {
222-
anchor: self.anchor - 1,
223-
head: self.head,
224-
horiz: None,
225-
},
226-
std::cmp::Ordering::Equal => *self,
227-
}
228-
}
229-
230212
/// Returns a range that encompasses both input ranges.
231213
///
232214
/// This is like `extend()`, but tries to negotiate the

helix-term/src/commands.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4867,8 +4867,9 @@ fn increment_impl(cx: &mut Context, amount: i64) {
48674867
}
48684868

48694869
if !changes.is_empty() {
4870-
let new_selection_primary =
4871-
selection.primary_index().min(new_selection_ranges.len() - 1);
4870+
let new_selection_primary = selection
4871+
.primary_index()
4872+
.min(new_selection_ranges.len() - 1);
48724873
let new_selection = Selection::new(new_selection_ranges, new_selection_primary);
48734874

48744875
let transaction = Transaction::change(doc.text(), changes.into_iter());

0 commit comments

Comments
 (0)