aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorPascal Kuthe2023-06-20 19:35:12 +0000
committerBlaž Hrastnik2023-06-25 16:32:31 +0000
commitd491e234f4eb4d8c3869f44ab71fedf022dc463e (patch)
treedf56999f77fadfbaa18aab1a9531a2e9d566af3c /helix-lsp
parent6c6923c39eae8b176d4deb7779ab19dcebb326ea (diff)
map positions through changes in O(N)
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/lib.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index d053dbf9..277a4c28 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -377,7 +377,7 @@ pub mod util {
.expect("transaction must be valid for primary selection");
let removed_text = text.slice(removed_start..removed_end);
- let (transaction, selection) = Transaction::change_by_selection_ignore_overlapping(
+ let (transaction, mut selection) = Transaction::change_by_selection_ignore_overlapping(
doc,
selection,
|range| {
@@ -420,6 +420,11 @@ pub mod util {
return transaction;
}
+ // Don't normalize to avoid merging/reording selections which would
+ // break the association between tabstops and selections. Most ranges
+ // will be replaced by tabstops anyways and the final selection will be
+ // normalized anyways
+ selection = selection.map_no_normalize(changes);
let mut mapped_selection = SmallVec::with_capacity(selection.len());
let mut mapped_primary_idx = 0;
let primary_range = selection.primary();
@@ -428,7 +433,6 @@ pub mod util {
mapped_primary_idx = mapped_selection.len()
}
- let range = range.map(changes);
let tabstops = tabstops.first().filter(|tabstops| !tabstops.is_empty());
let Some(tabstops) = tabstops else{
// no tabstop normal mapping