Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yue4u
Copy link

@yue4u yue4u commented Sep 18, 2023

close #193355

This is a sample PR for discussion for now.

}

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 },
Copy link
Author

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

Copy link
Author

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

{ 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 },
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change existing behavior so might need discussion

{ 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 },
{ 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 },
Copy link
Author

Choose a reason for hiding this comment

The 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

@justschen
Copy link
Contributor

@mjbvz this may actually help in this PR regarding #191854. ideally, I'd like to isolate quickfixes based on a more specific type, not show refactorings in a small subset of cases, or be able to differentiate between a regular quickfix or a source.fixall.

atm, from CodeActionKind, you can only see if the CodeActionItem.action.kind is of a kind (quickfix, refactor, surround) but not what specific action within each subset is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some code actions are de-prioritized in codeActionGroups
3 participants