diff options
author | Blaž Hrastnik | 2020-09-13 14:38:54 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-09-13 14:40:11 +0000 |
commit | 96db02742e85648e4ce0c2ab9b7cd239bdb763f8 (patch) | |
tree | 92a08a66356cf7ced125be65add857904e7df11a /helix-core/src/selection.rs | |
parent | 0427acd18cc06adec49783818107d1d5e2afc2ab (diff) |
Simplify some more code.
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r-- | helix-core/src/selection.rs | 12 |
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) } |