summaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorUrgau2023-02-11 17:45:30 +0000
committerBlaž Hrastnik2023-03-08 01:48:35 +0000
commitec6e575a408372400b7789b90cdf6ac271f51182 (patch)
treee1b617cad8096c010cd8c82ee2bdb86ab78beba2 /helix-core
parentba24cfe9125eda97346e3ceee42686fb9f46046f (diff)
Correctly handle multiple cursors with LSP snippets
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/selection.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index 0ac2c680..0db7634c 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -578,6 +578,16 @@ impl Selection {
self.normalize()
}
+ /// Takes a closure and maps each `Range` over the closure to multiple `Range`s.
+ pub fn transform_iter<F, I>(mut self, f: F) -> Self
+ where
+ F: FnMut(Range) -> I,
+ I: Iterator<Item = Range>,
+ {
+ self.ranges = self.ranges.into_iter().flat_map(f).collect();
+ self.normalize()
+ }
+
// Ensures the selection adheres to the following invariants:
// 1. All ranges are grapheme aligned.
// 2. All ranges are at least 1 character wide, unless at the