Update CodeActionOnSaveParticipant#108193
Merged
mjbvz merged 2 commits intomicrosoft:masterfrom Nov 20, 2020
Merged
Conversation
Add filtering CodeActionKind.SourceFixAll derivatives for codeActionsOnSave
mjbvz
reviewed
Oct 20, 2020
| let codeActionsOnSave = settingItems | ||
| .map(x => new CodeActionKind(x)); | ||
|
|
||
| if (!excludedActions.some(a => a.equals(CodeActionKind.SourceFixAll))) { |
Collaborator
There was a problem hiding this comment.
I don't think we should hardcode FixAll here. Instead, the logic should be:
- If there are multiple code actions on save
- Remove any of them that are strict subsets of the other ones (such as
source.fixAll.eslintbeing a subset ofsource.fixall)
Contributor
Author
There was a problem hiding this comment.
@mjbvz Thank you for the comment. I've updated the code to remove subsets from settingItems.
mjbvz
reviewed
Nov 4, 2020
| const actionSeeds = new Set<string>(); | ||
|
|
||
| // Remove subsets | ||
| const len = settingItems.length; |
Collaborator
There was a problem hiding this comment.
Instead of nested for loops, can you use array.filter? That should simplify the logic
Collaborator
|
Merging and will look at using |
mjbvz
added a commit
that referenced
this pull request
Nov 21, 2020
Contributor
Author
|
@mjbvz Sorry that I missed your comment. Thank you for your commit and merging! |
chenjigeng
pushed a commit
to chenjigeng/vscode
that referenced
this pull request
Nov 22, 2020
* Update CodeActionOnSaveParticipant Add filtering CodeActionKind.SourceFixAll derivatives for codeActionsOnSave * Add CodeActionOnSaveParticipant#createCodeActionsOnSave method to remove subsets. Fixes microsoft#106924.
chenjigeng
pushed a commit
to chenjigeng/vscode
that referenced
this pull request
Nov 22, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #106924.
I updated
CodeActionOnSaveParticipant#participatemethod to filter out CodeActionKind with 'source.fixAll.eslint' from codeActionsOnSave when "source.fixAll" is true.The reason why the eslint code action provider is called twice with the settings:
is as follows.
codeActionsOnSavearray has twoCodeActionKindswith values of 'source.fixAll' and 'source.fixAll.eslint'vscode/src/vs/workbench/contrib/codeEditor/browser/saveParticipants.ts
Lines 290 to 291 in e1515f7
getActionsToRunmethod returnsCodeActionSetwith provider from eslint for both of them.vscode/src/vs/workbench/contrib/codeEditor/browser/saveParticipants.ts
Lines 343 to 344 in e1515f7
Should I add filtering code for other CodeActionKind such as SourceOrganizeImports, Refactor, etc...?
Please let me know, in the first place, if there are better approaches.