Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 84992c2

Browse files
committed
Take updated VFS span type into account
From commit: rust-dev-tools/rls-vfs@62ee1b9.
1 parent 8ec1bc6 commit 84992c2

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions/notifications.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::actions::{FileWatch, InitActionContext, VersionOrdering};
1414
use crate::config::Config;
1515
use crate::Span;
1616
use log::{debug, trace, warn};
17-
use rls_vfs::{Change, SpanAtom};
17+
use rls_vfs::{Change, Span as VfsSpan, SpanLength as VfsSpanLength, Utf16CodeUnit};
1818
use serde::de::Error;
1919
use serde::Deserialize;
2020
use serde_json;
@@ -106,17 +106,16 @@ impl BlockingNotificationAction for DidChangeTextDocument {
106106
}
107107
}
108108

109-
let changes: Vec<Change> = params
109+
// LSP sends UTF-16 code units based offsets and length
110+
let changes: Vec<Change<Utf16CodeUnit>> = params
110111
.content_changes
111112
.iter()
112113
.map(|i| {
113114
if let Some(range) = i.range {
114115
let range = ls_util::range_to_rls(range);
115116
Change::ReplaceText {
116-
// LSP uses UTF-16 code units based offsets and length
117-
atom: SpanAtom::Utf16CodeUnit,
118-
span: Span::from_range(range, file_path.clone()),
119-
len: i.range_length,
117+
span: VfsSpan::<Utf16CodeUnit>::from(Span::from_range(range, file_path.clone())),
118+
len: i.range_length.map(VfsSpanLength::from),
120119
text: i.text.clone(),
121120
}
122121
} else {

tests/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,13 +1144,13 @@ fn cmd_format_utf16_range() {
11441144
eprintln!("{:#?}", json);
11451145

11461146
let result = json["result"].as_array().unwrap();
1147-
let newText: Vec<_> = result
1147+
let new_text: Vec<_> = result
11481148
.into_iter()
11491149
.map(|o| o["newText"].as_str().unwrap())
11501150
.collect();
11511151
// Actual formatting isn't important - what is, is that the buffer isn't
11521152
// malformed and code stays semantically equivalent.
1153-
assert_eq!(newText, vec!["/* 😢😢😢😢😢😢😢 */\nfn main() {}\n"]);
1153+
assert_eq!(new_text, vec!["/* 😢😢😢😢😢😢😢 */\nfn main() {}\n"]);
11541154

11551155
rls.shutdown(rls_timeout());
11561156
}

0 commit comments

Comments
 (0)