Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): avoid calling client while holding lock #18197

Merged
merged 16 commits into from
Mar 15, 2023
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
dsherret committed Feb 28, 2023
commit f08a5bf6ecb6001005a19920cfe53c67fdf9012e
5 changes: 5 additions & 0 deletions cli/lsp/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,11 @@ impl Documents {
}

pub fn open_root(&mut self, root_dir: &Path) {
// todo(THIS PR): this is wrong. We should probably do this when
// updating the configuration and it should be based on the enabled
// paths rather than pulling in everything. Additionally, we should
// skip searching certain directories by default like node_modules
// and .git
let mut fs_docs = self.file_system_docs.lock();
let resolver = self.resolver.as_graph_resolver();

Expand Down
6 changes: 3 additions & 3 deletions cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2767,16 +2767,16 @@ 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(true, true);
let all_docs = documents.documents(false, true);

let mut result = Vec::with_capacity(open_docs.len() + 1);
let mut result = Vec::with_capacity(all_docs.len() + 1);

if documents.has_injected_types_node_package() {
// ensure this is first so it resolves the node types first
result.push("asset:https:///node_types.d.ts".to_string());
}

result.extend(open_docs.into_iter().map(|d| d.specifier().to_string()));
result.extend(all_docs.into_iter().map(|d| d.specifier().to_string()));
result
}

Expand Down