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

Commit b672685

Browse files
committed
Take updated VFS span type into account
From commit: rust-dev-tools/rls-vfs@3fde048.
1 parent 5072570 commit b672685

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/actions/notifications.rs

Lines changed: 6 additions & 5 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, VfsSpan};
1818
use serde::de::Error;
1919
use serde::Deserialize;
2020
use serde_json;
@@ -113,10 +113,11 @@ impl BlockingNotificationAction for DidChangeTextDocument {
113113
if let Some(range) = i.range {
114114
let range = ls_util::range_to_rls(range);
115115
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,
116+
// LSP sends UTF-16 code units based offsets and length
117+
span: VfsSpan::from_utf16(
118+
Span::from_range(range, file_path.clone()),
119+
i.range_length
120+
),
120121
text: i.text.clone(),
121122
}
122123
} 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)