diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-03-27 03:10:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-27 03:10:23 +0000 |
commit | e1e1da2a04f627f058dc33355a31d67abb1616b6 (patch) | |
tree | 123e0e46755553f5872aa25cb1205eadf62d1893 /cli/lsp/analysis.rs | |
parent | 34a651ea2ed36063fbe58d5de0d0c41ae9fbd980 (diff) |
fix(lsp): prefer cache over tsc quick fixes (#23093)
Diffstat (limited to 'cli/lsp/analysis.rs')
-rw-r--r-- | cli/lsp/analysis.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 652697a9e..cd7d45928 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -647,6 +647,10 @@ fn is_preferred( } } true + } else if let CodeActionKind::Deno(_) = i { + // This is to make sure 'Remove import' isn't preferred over 'Cache + // dependencies'. + return false; } else { true } @@ -1031,18 +1035,18 @@ impl CodeActionCollection { /// Move out the code actions and return them as a `CodeActionResponse`. pub fn get_response(self) -> lsp::CodeActionResponse { - // Prefer TSC fixes first, then Deno fixes, then Deno lint fixes. - let (tsc, rest): (Vec<_>, Vec<_>) = self + // Prefer Deno fixes first, then TSC fixes, then Deno lint fixes. + let (deno, rest): (Vec<_>, Vec<_>) = self .actions .into_iter() - .partition(|a| matches!(a, CodeActionKind::Tsc(..))); - let (deno, deno_lint): (Vec<_>, Vec<_>) = rest - .into_iter() .partition(|a| matches!(a, CodeActionKind::Deno(_))); + let (tsc, deno_lint): (Vec<_>, Vec<_>) = rest + .into_iter() + .partition(|a| matches!(a, CodeActionKind::Tsc(..))); - tsc + deno .into_iter() - .chain(deno) + .chain(tsc) .chain(deno_lint) .map(|k| match k { CodeActionKind::Deno(c) => lsp::CodeActionOrCommand::CodeAction(c), |