From f62018e80f6269149784246fdc6b22539b9c0bb8 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Sat, 20 Apr 2024 13:18:43 -0700 Subject: [PATCH] perf(lsp): Pass code action trigger kind to TSC (#23466) --- cli/lsp/language_server.rs | 1 + cli/lsp/tsc.rs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 2529df6f7c..fdd497bbac 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1879,6 +1879,7 @@ impl Inner { &self.config, &specifier, )), + params.context.trigger_kind, only, ) .await?; diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 16cca30e15..2873ba703b 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -490,8 +490,14 @@ impl TsServer { specifier: ModuleSpecifier, range: Range, preferences: Option, + trigger_kind: Option, only: String, ) -> Result, LspError> { + let trigger_kind: Option<&str> = trigger_kind.map(|reason| match reason { + lsp::CodeActionTriggerKind::INVOKED => "invoked", + lsp::CodeActionTriggerKind::AUTOMATIC => "implicit", + _ => unreachable!(), + }); let req = TscRequest { method: "getApplicableRefactors", // https://github.com/denoland/deno/blob/v1.37.1/cli/tsc/dts/typescript.d.ts#L6274 @@ -499,7 +505,7 @@ impl TsServer { self.specifier_map.denormalize(&specifier), { "pos": range.start, "end": range.end }, preferences.unwrap_or_default(), - json!(null), + trigger_kind, only, ]), };