aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-14 06:30:15 +0000
committerBlaž Hrastnik2021-04-14 06:39:31 +0000
commit3e5f24a9d5cec26697a75e515bff46de418b32da (patch)
treede3cf4a3be699798d3797f5af2d52a1e58227155 /helix-view/src
parent811f952a41177242f7dfa4d66f2b16157f918718 (diff)
lsp: support both utf-8 and utf-16 offsets.
Still need to implement the clangd encoding negotiation, but it's a start. Should also manually override to utf8 for pyls.
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 8e836f03..a04600b6 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -406,7 +406,7 @@ mod test {
#[test]
fn changeset_to_changes() {
- use helix_lsp::{lsp, Client};
+ use helix_lsp::{lsp, Client, OffsetEncoding};
let text = Rope::from("hello");
let mut doc = Document::new(text);
let view = ViewId::default();
@@ -417,7 +417,12 @@ mod test {
let transaction = Transaction::insert(doc.text(), doc.selection(view), " world".into());
let old_doc = doc.text().clone();
doc.apply(&transaction, view);
- let changes = Client::changeset_to_changes(&old_doc, doc.text(), transaction.changes());
+ let changes = Client::changeset_to_changes(
+ &old_doc,
+ doc.text(),
+ transaction.changes(),
+ OffsetEncoding::Utf8,
+ );
assert_eq!(
changes,
@@ -436,7 +441,12 @@ mod test {
let transaction = transaction.invert(&old_doc);
let old_doc = doc.text().clone();
doc.apply(&transaction, view);
- let changes = Client::changeset_to_changes(&old_doc, doc.text(), transaction.changes());
+ let changes = Client::changeset_to_changes(
+ &old_doc,
+ doc.text(),
+ transaction.changes(),
+ OffsetEncoding::Utf8,
+ );
// line: 0-based.
// col: 0-based, gaps between chars.
@@ -468,7 +478,12 @@ mod test {
// aeilou
let old_doc = doc.text().clone();
doc.apply(&transaction, view);
- let changes = Client::changeset_to_changes(&old_doc, doc.text(), transaction.changes());
+ let changes = Client::changeset_to_changes(
+ &old_doc,
+ doc.text(),
+ transaction.changes(),
+ OffsetEncoding::Utf8,
+ );
assert_eq!(
changes,