summaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-09-21 15:51:49 +0000
committerBlaž Hrastnik2021-09-24 01:30:28 +0000
commit2e0803c8d9ec0028c0d018be251c7c2b781247b3 (patch)
tree342c9a4745c8becd490c1ecddaa38b11d24e6b9a /helix-core/src/selection.rs
parent75dba1f9560c6ea579e79ff074e60ba2fb87ca63 (diff)
Implement 'remove_primary_selection' as Alt-,
This allows removing search matches from the selection Fixes #713
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r--helix-core/src/selection.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index a3ea2ed4..755ee679 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -360,6 +360,15 @@ impl Selection {
self.normalize()
}
+ /// Adds a new range to the selection and makes it the primary range.
+ pub fn remove(mut self, index: usize) -> Self {
+ self.ranges.remove(index);
+ if index < self.primary_index || self.primary_index == self.ranges.len() {
+ self.primary_index -= 1;
+ }
+ self
+ }
+
/// Map selections over a set of changes. Useful for adjusting the selection position after
/// applying changes to a document.
pub fn map(self, changes: &ChangeSet) -> Self {