diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-12-03 22:07:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-03 22:07:40 +0000 |
commit | 0a738dc49df7a17416f4d62f62282292c1bb2174 (patch) | |
tree | 70b6514703490b496eca3f15b6f7d331f24b69eb /cli/lsp/diagnostics.rs | |
parent | 28c527c8f5855f4051cc02973a647741d20cb0fc (diff) |
perf(lsp): check tsc request cancellation before execution (#21447)
Diffstat (limited to 'cli/lsp/diagnostics.rs')
-rw-r--r-- | cli/lsp/diagnostics.rs | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index 00f535391..1349029c3 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -502,7 +502,12 @@ impl DiagnosticsServer { ) .await .map_err(|err| { - error!("Error generating TypeScript diagnostics: {}", err); + if !token.is_cancelled() { + error!( + "Error generating TypeScript diagnostics: {}", + err + ); + } }) .unwrap_or_default(); @@ -1616,35 +1621,6 @@ let c: number = "a"; } #[tokio::test] - async fn test_cancelled_ts_diagnostics_request() { - let temp_dir = TempDir::new(); - let (snapshot, cache_location) = setup( - &temp_dir, - &[( - "file:///a.ts", - r#"export let a: string = 5;"#, - 1, - LanguageId::TypeScript, - )], - None, - ); - let snapshot = Arc::new(snapshot); - let cache = - Arc::new(GlobalHttpCache::new(cache_location, RealDenoCacheEnv)); - let ts_server = TsServer::new(Default::default(), cache); - - let config = mock_config(); - let token = CancellationToken::new(); - token.cancel(); - let diagnostics = - generate_ts_diagnostics(snapshot.clone(), &config, &ts_server, token) - .await - .unwrap(); - // should be none because it's cancelled - assert_eq!(diagnostics.len(), 0); - } - - #[tokio::test] async fn test_deno_diagnostics_with_import_map() { let temp_dir = TempDir::new(); let (snapshot, _) = setup( |