-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cover more code action kind in codeActionGroups #193356
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,18 +17,22 @@ interface ActionGroup { | |
readonly kind: CodeActionKind; | ||
readonly title: string; | ||
readonly icon?: ThemeIcon; | ||
readonly exact?: boolean; | ||
} | ||
|
||
const uncategorizedCodeActionGroup = Object.freeze<ActionGroup>({ kind: CodeActionKind.Empty, title: localize('codeAction.widget.id.more', 'More Actions...') }); | ||
|
||
const codeActionGroups = Object.freeze<ActionGroup[]>([ | ||
{ kind: CodeActionKind.QuickFix, title: localize('codeAction.widget.id.quickfix', 'Quick Fix') }, | ||
{ kind: CodeActionKind.Refactor, title: localize('codeAction.widget.id.refactor', 'Refactor'), icon: Codicon.wrench, exact: true }, | ||
{ kind: CodeActionKind.RefactorExtract, title: localize('codeAction.widget.id.extract', 'Extract'), icon: Codicon.wrench }, | ||
{ kind: CodeActionKind.RefactorInline, title: localize('codeAction.widget.id.inline', 'Inline'), icon: Codicon.wrench }, | ||
{ kind: CodeActionKind.RefactorRewrite, title: localize('codeAction.widget.id.convert', 'Rewrite'), icon: Codicon.wrench }, | ||
{ kind: CodeActionKind.RefactorMove, title: localize('codeAction.widget.id.move', 'Move'), icon: Codicon.wrench }, | ||
{ kind: CodeActionKind.SurroundWith, title: localize('codeAction.widget.id.surround', 'Surround With'), icon: Codicon.symbolSnippet }, | ||
{ kind: CodeActionKind.Source, title: localize('codeAction.widget.id.source', 'Source Action'), icon: Codicon.symbolFile }, | ||
{ kind: CodeActionKind.Source, title: localize('codeAction.widget.id.source', 'Source Action'), icon: Codicon.symbolFile, exact: true }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will change existing behavior so might need discussion |
||
{ kind: CodeActionKind.SourceFixAll, title: localize('codeAction.widget.id.source.fixAll', 'Source Action Fix All'), icon: Codicon.symbolFile }, | ||
{ kind: CodeActionKind.SourceOrganizeImports, title: localize('codeAction.widget.id.source.organizeImports', 'Source Action Organize Imports'), icon: Codicon.symbolFile }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Question]: Is it better to keep the order as same as the documentation? It's doable via typecheck but I couldn't find any existing types to reuse https://code.visualstudio.com/api/references/vscode-api#CodeActionKind |
||
uncategorizedCodeActionGroup, | ||
]); | ||
|
||
|
@@ -56,7 +60,7 @@ export function toMenuItems( | |
for (const action of inputCodeActions) { | ||
const kind = action.action.kind ? new CodeActionKind(action.action.kind) : CodeActionKind.None; | ||
for (const menuEntry of menuEntries) { | ||
if (menuEntry.group.kind.contains(kind)) { | ||
if (menuEntry.group.exact ? menuEntry.group.kind.equals(kind) : menuEntry.group.kind.contains(kind)) { | ||
menuEntry.actions.push(action); | ||
break; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very sure where these localize keys are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without setting this to exact match it'll catch all following sub action kinds