Fix sort order of fixes with diagnostics (#157682)

Fixes #157634
This commit is contained in:
Matt Bierner 2022-08-09 11:06:36 -07:00 committed by GitHub
parent 38477bf5f5
commit b247c10516
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -72,7 +72,7 @@ class ManagedCodeActionSet extends Disposable implements CodeActionSet {
private static codeActionsComparator({ action: a }: CodeActionItem, { action: b }: CodeActionItem): number {
if (isNonEmptyArray(a.diagnostics)) {
return -1;
return isNonEmptyArray(b.diagnostics) ? ManagedCodeActionSet.codeActionsPreferredComparator(a, b) : -1;
} else if (isNonEmptyArray(b.diagnostics)) {
return 1;
} else {

View file

@ -119,9 +119,9 @@ suite('CodeAction', () => {
disposables.add(registry.register('fooLang', provider));
const expected = [
// CodeActions with a diagnostics array are shown first ordered by diagnostics.message
new CodeActionItem(testData.diagnostics.abc, provider),
// CodeActions with a diagnostics array are shown first without further sorting
new CodeActionItem(testData.diagnostics.bcd, provider),
new CodeActionItem(testData.diagnostics.abc, provider),
// CodeActions without diagnostics are shown in the given order without any further sorting
new CodeActionItem(testData.command.abc, provider),