Skip to content

Commit

Permalink
perf(lsp): Pass code action trigger kind to TSC (denoland#23466)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed Apr 20, 2024
1 parent c0f40ed commit f62018e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,7 @@ impl Inner {
&self.config,
&specifier,
)),
params.context.trigger_kind,
only,
)
.await?;
Expand Down
8 changes: 7 additions & 1 deletion cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,22 @@ impl TsServer {
specifier: ModuleSpecifier,
range: Range<u32>,
preferences: Option<UserPreferences>,
trigger_kind: Option<lsp::CodeActionTriggerKind>,
only: String,
) -> Result<Vec<ApplicableRefactorInfo>, 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
args: json!([
self.specifier_map.denormalize(&specifier),
{ "pos": range.start, "end": range.end },
preferences.unwrap_or_default(),
json!(null),
trigger_kind,
only,
]),
};
Expand Down

0 comments on commit f62018e

Please sign in to comment.