diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-03-30 17:47:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-30 17:47:53 -0400 |
commit | 772201449713fbefad6c42b9ce545a5bb2d7499b (patch) | |
tree | 3a0e0448ca4116cd5ed4c1ba7dafb331ad6215e3 /cli/lsp/tsc.rs | |
parent | 02e01b171f29f4f6c23d738b0756b7d9b7eaa020 (diff) |
fix(lsp): include all diagnosable documents on initialize (#17979)
Closes https://github.com/denoland/vscode_deno/issues/797
Closes https://github.com/denoland/deno/issues/11190
Closes https://github.com/denoland/vscode_deno/issues/811
Closes https://github.com/denoland/vscode_deno/issues/761
Closes https://github.com/denoland/vscode_deno/issues/585
Closes https://github.com/denoland/vscode_deno/issues/561
Closes https://github.com/denoland/vscode_deno/issues/410
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r-- | cli/lsp/tsc.rs | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index e846cc496..f02668910 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -2803,9 +2803,9 @@ fn op_respond(state: &mut OpState, args: Response) -> bool { fn op_script_names(state: &mut OpState) -> Vec<String> { let state = state.borrow_mut::<State>(); let documents = &state.state_snapshot.documents; - let open_docs = documents.documents(DocumentsFilter::OpenDiagnosable); - let mut result = Vec::new(); + let all_docs = documents.documents(DocumentsFilter::AllDiagnosable); let mut seen = HashSet::new(); + let mut result = Vec::new(); if documents.has_injected_types_node_package() { // ensure this is first so it resolves the node types first @@ -2822,23 +2822,17 @@ fn op_script_names(state: &mut OpState) -> Vec<String> { } // finally include the documents and all their dependencies - for doc in &open_docs { - let specifier = doc.specifier(); - if seen.insert(specifier.as_str()) { - result.push(specifier.to_string()); - } - } - - // and then all their dependencies (do this after to avoid exists calls) - for doc in &open_docs { - for dep in doc.dependencies().values() { - if let Some(specifier) = dep.get_type().or_else(|| dep.get_code()) { - if seen.insert(specifier.as_str()) { - // only include dependencies we know to exist otherwise typescript will error - if documents.exists(specifier) { - result.push(specifier.to_string()); - } - } + for doc in &all_docs { + let specifiers = std::iter::once(doc.specifier()).chain( + doc + .dependencies() + .values() + .filter_map(|dep| dep.get_type().or_else(|| dep.get_code())), + ); + for specifier in specifiers { + if seen.insert(specifier.as_str()) && documents.exists(specifier) { + // only include dependencies we know to exist otherwise typescript will error + result.push(specifier.to_string()); } } } |