aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
diff options
context:
space:
mode:
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)
}