aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-13 14:38:54 +0000
committerBlaž Hrastnik2020-09-13 14:40:11 +0000
commit96db02742e85648e4ce0c2ab9b7cd239bdb763f8 (patch)
tree92a08a66356cf7ced125be65add857904e7df11a /helix-core/src/selection.rs
parent0427acd18cc06adec49783818107d1d5e2afc2ab (diff)
Simplify some more code.
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r--helix-core/src/selection.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index 2ae2d7c8..80bb6a0c 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -100,8 +100,8 @@ impl Range {
#[derive(Debug, Clone)]
pub struct Selection {
// TODO: decide how many ranges to inline SmallVec<[Range; 1]>
- pub(crate) ranges: SmallVec<[Range; 1]>,
- pub(crate) primary_index: usize,
+ ranges: SmallVec<[Range; 1]>,
+ primary_index: usize,
}
impl Selection {
@@ -205,6 +205,14 @@ impl Selection {
}
}
+ // fast path for a single selection (cursor)
+ if ranges.len() == 1 {
+ return Selection {
+ ranges,
+ primary_index: 0,
+ };
+ }
+
// TODO: only normalize if needed (any ranges out of order)
normalize(ranges, primary_index)
}