summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/lsp/tsc.rs10
-rw-r--r--cli/tests/integration/lsp_tests.rs74
-rw-r--r--cli/tsc/00_typescript.js6
3 files changed, 85 insertions, 5 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index f02668910..2980e546b 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -2779,13 +2779,13 @@ fn op_resolve(
.collect(),
)
}
- None => Err(custom_error(
- "NotFound",
- format!(
+ None => {
+ lsp_warn!(
"Error resolving. Referring specifier \"{}\" was not found.",
args.base
- ),
- )),
+ );
+ Ok(vec![None; args.specifiers.len()])
+ }
};
state.performance.measure(mark);
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 15f0ea490..50d3e4be2 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -7417,3 +7417,77 @@ fn lsp_closed_file_find_references() {
client.shutdown();
}
+
+#[test]
+fn lsp_data_urls_with_jsx_compiler_option() {
+ let context = TestContextBuilder::new().use_temp_cwd().build();
+ let temp_dir = context.temp_dir();
+ temp_dir.write(
+ "deno.json",
+ r#"{ "compilerOptions": { "jsx": "react-jsx" } }"#,
+ );
+
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+
+ let uri = Url::from_file_path(temp_dir.path().join("main.ts")).unwrap();
+
+ let diagnostics = client.did_open(json!({
+ "textDocument": {
+ "uri": uri,
+ "languageId": "typescript",
+ "version": 1,
+ "text": "import a from \"data:application/typescript,export default 5;\";\na;"
+ }
+ })).viewed();
+
+ // there will be a diagnostic about not having cached the data url
+ assert_eq!(diagnostics.len(), 1);
+ assert_eq!(
+ diagnostics[0].code,
+ Some(lsp::NumberOrString::String("no-cache-data".to_string()))
+ );
+
+ // so cache it
+ client.write_request(
+ "deno/cache",
+ json!({
+ "referrer": {
+ "uri": uri,
+ },
+ "uris": [],
+ }),
+ );
+
+ let res = client.write_request(
+ "textDocument/references",
+ json!({
+ "textDocument": {
+ "uri": uri
+ },
+ "position": { "line": 1, "character": 1 },
+ "context": {
+ "includeDeclaration": false
+ }
+ }),
+ );
+
+ assert_eq!(
+ res,
+ json!([{
+ "uri": uri,
+ "range": {
+ "start": { "line": 0, "character": 7 },
+ "end": { "line": 0, "character": 8 }
+ }
+ }, {
+ "uri": uri,
+ "range": {
+ "start": { "line": 1, "character": 0 },
+ "end": { "line": 1, "character": 1 }
+ }
+ }])
+ );
+
+ client.shutdown();
+}
diff --git a/cli/tsc/00_typescript.js b/cli/tsc/00_typescript.js
index 6bbd968a9..bae91eee2 100644
--- a/cli/tsc/00_typescript.js
+++ b/cli/tsc/00_typescript.js
@@ -6712,6 +6712,9 @@ ${lanes.join("\n")}
}
return ~path.length;
}
+ if (path.startsWith("data:")) {
+ return ~path.length;
+ }
return 0;
}
function getRootLength(path) {
@@ -6870,6 +6873,9 @@ ${lanes.join("\n")}
}
function ensureTrailingDirectorySeparator(path) {
if (!hasTrailingDirectorySeparator(path)) {
+ if (path.startsWith("data:")) {
+ return path;
+ }
return path + directorySeparator;
}
return path;