diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-03-15 10:34:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 14:34:23 +0000 |
commit | 7070b8ed50f13d95d926b19ed7d7ce9fc0d6d4f3 (patch) | |
tree | 1cba1972e1b7fcea1706a893984a3be12093cf1c /test_util/src | |
parent | 2ca160702795bb1b92196a848f7e4814d23ed32c (diff) |
fix(lsp): avoid calling client while holding lock (#18197)
Diffstat (limited to 'test_util/src')
-rw-r--r-- | test_util/src/lsp.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test_util/src/lsp.rs b/test_util/src/lsp.rs index 7578aedf3..786a2dee5 100644 --- a/test_util/src/lsp.rs +++ b/test_util/src/lsp.rs @@ -148,6 +148,11 @@ impl LspStdoutReader { self.pending_messages.0.lock().len() } + pub fn output_pending_messages(&self) { + let messages = self.pending_messages.0.lock(); + eprintln!("{:?}", messages); + } + pub fn had_message(&self, is_match: impl Fn(&LspMessage) -> bool) -> bool { self.read_messages.iter().any(&is_match) || self.pending_messages.0.lock().iter().any(&is_match) @@ -453,6 +458,9 @@ impl LspClientBuilder { self } + // not deprecated, this is just here so you don't accidentally + // commit code with this enabled + #[deprecated] pub fn print_stderr(&mut self) -> &mut Self { self.print_stderr = true; self @@ -541,6 +549,7 @@ impl LspClient { } pub fn queue_len(&self) -> usize { + self.reader.output_pending_messages(); self.reader.pending_len() } @@ -552,11 +561,25 @@ impl LspClient { &mut self, do_build: impl Fn(&mut InitializeParamsBuilder), ) { + self.initialize_with_config( + do_build, + json!([{ + "enable": true + }]), + ) + } + + pub fn initialize_with_config( + &mut self, + do_build: impl Fn(&mut InitializeParamsBuilder), + config: Value, + ) { let mut builder = InitializeParamsBuilder::new(); builder.set_root_uri(self.context.deno_dir().uri()); do_build(&mut builder); self.write_request("initialize", builder.build()); self.write_notification("initialized", json!({})); + self.handle_configuration_request(config); } pub fn did_open(&mut self, params: Value) -> CollectedDiagnostics { |