aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src')
-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 {