From 4875cc00d5b7302e87e9f339df3aa649f739951e Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 10 May 2019 15:43:27 -0700 Subject: [PATCH] Use correct sorting for code action on save Fixes #73344 --- .../editor/contrib/codeAction/codeActionTrigger.ts | 6 +++++- .../api/browser/mainThreadSaveParticipant.ts | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/vs/editor/contrib/codeAction/codeActionTrigger.ts b/src/vs/editor/contrib/codeAction/codeActionTrigger.ts index 15e90604ed6..f0fb3b3e6bf 100644 --- a/src/vs/editor/contrib/codeAction/codeActionTrigger.ts +++ b/src/vs/editor/contrib/codeAction/codeActionTrigger.ts @@ -20,8 +20,12 @@ export class CodeActionKind { public readonly value: string ) { } + public equals(other: CodeActionKind): boolean { + return this.value === other.value; + } + public contains(other: CodeActionKind): boolean { - return this.value === other.value || startsWith(other.value, this.value + CodeActionKind.sep); + return this.equals(other) || startsWith(other.value, this.value + CodeActionKind.sep); } public intersects(other: CodeActionKind): boolean { diff --git a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts index 768c8283037..76bed28b12e 100644 --- a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts @@ -266,14 +266,18 @@ class CodeActionOnSaveParticipant implements ISaveParticipant { const codeActionsOnSave = Object.keys(setting) .filter(x => setting[x]).map(x => new CodeActionKind(x)) .sort((a, b) => { - if (a.value === CodeActionKind.SourceFixAll.value) { - return -1; - } - if (b.value === CodeActionKind.SourceFixAll.value) { + if (CodeActionKind.SourceFixAll.contains(a)) { + if (CodeActionKind.SourceFixAll.contains(b)) { + return 0; + } return 1; } + if (CodeActionKind.SourceFixAll.contains(b)) { + return -1; + } return 0; }); + if (!codeActionsOnSave.length) { return undefined; }