aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorPascal Kuthe2023-04-03 01:58:50 +0000
committerGitHub2023-04-03 01:58:50 +0000
commit1073dd632932d0c9131f6413a5ced69ee7096e60 (patch)
treec1cf0d75d82b6d03e1b71b161c4685c3b2b69dab /helix-term/src
parentbfe8d267fec4964c6981ae38d9e4f46cdebb61b7 (diff)
robustly handle invalid LSP ranges (#6512)
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/ui/completion.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index e0b1419c..bc216509 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -141,16 +141,12 @@ impl Completion {
}
};
- let start_offset =
- match util::lsp_pos_to_pos(doc.text(), edit.range.start, offset_encoding) {
- Some(start) => start as i128 - primary_cursor as i128,
- None => return Transaction::new(doc.text()),
- };
- let end_offset =
- match util::lsp_pos_to_pos(doc.text(), edit.range.end, offset_encoding) {
- Some(end) => end as i128 - primary_cursor as i128,
- None => return Transaction::new(doc.text()),
- };
+ let Some(range) = util::lsp_range_to_range(doc.text(), edit.range, offset_encoding) else{
+ return Transaction::new(doc.text());
+ };
+
+ let start_offset = range.anchor as i128 - primary_cursor as i128;
+ let end_offset = range.head as i128 - primary_cursor as i128;
(Some((start_offset, end_offset)), edit.new_text)
} else {