diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-09-18 17:39:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-18 17:39:28 +0100 |
commit | 87ddd1f04d2b71aadb3a8a5fb3e4ac15988947c1 (patch) | |
tree | c858f05a9b8faa217ba22125ca9953555fc750ae /cli/lsp/analysis.rs | |
parent | ee38bbbc8e716e0d91bf6558024240142d42f32c (diff) |
fix(lsp): restore tsc's quick fix ordering (#20545)
Diffstat (limited to 'cli/lsp/analysis.rs')
-rw-r--r-- | cli/lsp/analysis.rs | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 808f09dec..c1def6012 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -848,31 +848,23 @@ impl CodeActionCollection { /// Move out the code actions and return them as a `CodeActionResponse`. pub fn get_response(self) -> lsp::CodeActionResponse { - let mut actions = self.actions; - // Prefer TSC fixes first, then Deno fixes, then Deno lint fixes. - actions.sort_by(|a, b| match (a, b) { - (CodeActionKind::Deno(a), CodeActionKind::Deno(b)) => { - a.title.cmp(&b.title) - } - (CodeActionKind::DenoLint(a), CodeActionKind::DenoLint(b)) => { - a.title.cmp(&b.title) - } - (CodeActionKind::Tsc(a, _), CodeActionKind::Tsc(b, _)) => { - a.title.cmp(&b.title) - } - (CodeActionKind::Tsc(_, _), _) => Ordering::Less, - (CodeActionKind::Deno(_), CodeActionKind::Tsc(_, _)) => Ordering::Greater, - (CodeActionKind::Deno(_), CodeActionKind::DenoLint(_)) => Ordering::Less, - (CodeActionKind::DenoLint(_), _) => Ordering::Greater, - }); + let (tsc, 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(_))); - actions + tsc .into_iter() - .map(|i| match i { - CodeActionKind::Tsc(c, _) => lsp::CodeActionOrCommand::CodeAction(c), + .chain(deno) + .chain(deno_lint) + .map(|k| match k { CodeActionKind::Deno(c) => lsp::CodeActionOrCommand::CodeAction(c), CodeActionKind::DenoLint(c) => lsp::CodeActionOrCommand::CodeAction(c), + CodeActionKind::Tsc(c, _) => lsp::CodeActionOrCommand::CodeAction(c), }) .collect() } |