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

Commit

Permalink
Take updated VFS span type into account
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Nov 6, 2018
1 parent 5072570 commit b672685
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/actions/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::actions::{FileWatch, InitActionContext, VersionOrdering};
use crate::config::Config;
use crate::Span;
use log::{debug, trace, warn};
use rls_vfs::{Change, SpanAtom};
use rls_vfs::{Change, VfsSpan};
use serde::de::Error;
use serde::Deserialize;
use serde_json;
Expand Down Expand Up @@ -113,10 +113,11 @@ impl BlockingNotificationAction for DidChangeTextDocument {
if let Some(range) = i.range {
let range = ls_util::range_to_rls(range);
Change::ReplaceText {
// LSP uses UTF-16 code units based offsets and length
atom: SpanAtom::Utf16CodeUnit,
span: Span::from_range(range, file_path.clone()),
len: i.range_length,
// LSP sends UTF-16 code units based offsets and length
span: VfsSpan::from_utf16(
Span::from_range(range, file_path.clone()),
i.range_length
),
text: i.text.clone(),
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,13 +1144,13 @@ fn cmd_format_utf16_range() {
eprintln!("{:#?}", json);

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

rls.shutdown(rls_timeout());
}

0 comments on commit b672685

Please sign in to comment.