summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/lsp/tsc.rs9
-rw-r--r--tests/integration/lsp_tests.rs63
-rw-r--r--tests/testdata/subdir/exports.ts1
3 files changed, 73 insertions, 0 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index ce848c210..104024167 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -2115,8 +2115,13 @@ impl RenameLocations {
LspClientUrl,
lsp::TextDocumentEdit,
> = HashMap::new();
+ let mut includes_non_files = false;
for location in self.locations.iter() {
let specifier = resolve_url(&location.document_span.file_name)?;
+ if specifier.scheme() != "file" {
+ includes_non_files = true;
+ continue;
+ }
let uri = language_server.url_map.normalize_specifier(&specifier)?;
let asset_or_doc = language_server.get_asset_or_document(&specifier)?;
@@ -2146,6 +2151,10 @@ impl RenameLocations {
}));
}
+ if includes_non_files {
+ language_server.client.show_message(lsp::MessageType::WARNING, "The renamed symbol had references in non-file schemed modules. These have not been modified.");
+ }
+
Ok(lsp::WorkspaceEdit {
change_annotations: None,
changes: None,
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 9300413b5..8165cc86a 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -2461,6 +2461,69 @@ fn lsp_hover_deps_preserved_when_invalid_parse() {
client.shutdown();
}
+// Regression test for https://github.com/denoland/vscode_deno/issues/1068.
+#[test]
+fn lsp_rename_synbol_file_scheme_edits_only() {
+ let context = TestContextBuilder::new()
+ .use_http_server()
+ .use_temp_cwd()
+ .build();
+ let temp_dir = context.temp_dir();
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+ client.did_open(json!({
+ "textDocument": {
+ "uri": temp_dir.uri().join("file.ts").unwrap(),
+ "languageId": "typescript",
+ "version": 1,
+ "text": r#"
+ import { SEPARATOR } from "http://localhost:4545/subdir/exports.ts";
+ console.log(SEPARATOR);
+ "#,
+ },
+ }));
+ let res = client.write_request(
+ "textDocument/rename",
+ json!({
+ "textDocument": {
+ "uri": temp_dir.uri().join("file.ts").unwrap(),
+ },
+ "position": { "line": 1, "character": 17 },
+ "newName": "PATH_SEPARATOR",
+ }),
+ );
+ assert_eq!(
+ res,
+ json!({
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": temp_dir.uri().join("file.ts").unwrap(),
+ "version": 1,
+ },
+ "edits": [
+ {
+ "range": {
+ "start": { "line": 1, "character": 17 },
+ "end": { "line": 1, "character": 26 },
+ },
+ "newText": "PATH_SEPARATOR",
+ },
+ {
+ "range": {
+ "start": { "line": 2, "character": 20 },
+ "end": { "line": 2, "character": 29 },
+ },
+ "newText": "PATH_SEPARATOR",
+ },
+ ],
+ }
+ ],
+ })
+ );
+ client.shutdown();
+}
+
#[test]
fn lsp_hover_typescript_types() {
let context = TestContextBuilder::new()
diff --git a/tests/testdata/subdir/exports.ts b/tests/testdata/subdir/exports.ts
new file mode 100644
index 000000000..d5f8be342
--- /dev/null
+++ b/tests/testdata/subdir/exports.ts
@@ -0,0 +1 @@
+export const SEPARATOR = "/";