diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-08-29 09:43:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-29 09:43:11 +0100 |
commit | c31c93ce70c1147872d911c4a05c808d4078339b (patch) | |
tree | 3daa86a2d283982eab65748c6defeb675b9be026 | |
parent | fb7092fb43d5a6e5a29ca5b2f0de6683ee55f3e5 (diff) |
fix(lsp): delete test modules with all tests deleted (#20321)
Fixes https://github.com/denoland/vscode_deno/issues/899.
-rw-r--r-- | cli/lsp/testing/server.rs | 5 | ||||
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/cli/lsp/testing/server.rs b/cli/lsp/testing/server.rs index 638ab5b55..65a72bed4 100644 --- a/cli/lsp/testing/server.rs +++ b/cli/lsp/testing/server.rs @@ -109,6 +109,7 @@ impl TestServer { if let Some(Ok(parsed_source)) = document.maybe_parsed_source() { + let old_tds = tests.remove(specifier).unwrap_or_default(); let mut collector = TestCollector::new( specifier.clone(), parsed_source.text_info().clone(), @@ -127,6 +128,10 @@ impl TestServer { parsed_source.text_info(), ), ); + } else if !old_tds.is_empty() { + client.send_test_notification(as_delete_notification( + specifier.clone(), + )); } tests.insert(specifier.clone(), test_definitions); } diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 665fa6275..218b1db40 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -8549,6 +8549,32 @@ Deno.test({ _ => panic!("unexpected message {}", json!(notification)), } + // Regression test for https://github.com/denoland/vscode_deno/issues/899. + temp_dir.write("./test.ts", ""); + client.write_notification( + "textDocument/didChange", + json!({ + "textDocument": { + "uri": temp_dir.uri().join("test.ts").unwrap(), + "version": 2 + }, + "contentChanges": [{ "text": "" }], + }), + ); + + assert_eq!(client.read_diagnostics().all().len(), 0); + + let (method, notification) = client.read_notification::<Value>(); + assert_eq!(method, "deno/testModuleDelete"); + assert_eq!( + notification, + Some(json!({ + "textDocument": { + "uri": temp_dir.uri().join("test.ts").unwrap() + } + })) + ); + client.shutdown(); } |