Skip to content

intellisense for code actions on save - #215475

Merged
Justin Chen (justschen) merged 5 commits into
microsoft:mainfrom
justschen:justin/onsave
Jun 24, 2024
Merged

Justin Chen (justschen) merged 5 commits into
microsoft:mainfrom
justschen:justin/onsave

Conversation

@justschen

@justschen Justin Chen (justschen) commented Jun 13, 2024 •

Copy link
Copy Markdown
Collaborator

fixes #161284
related #212381

issue: no intellisense because of how we get contributed or default code actions on save
https://github.com/justschen/vscode/blob/a6bda062d6a861071758ded8abc781af37a083e2/src/vs/workbench/contrib/codeActions/common/codeActionsExtensionPoint.ts#L69

atm, we only search contributions if they statically contribute code actions (ie, https://github.com/justschen/vscode/blob/a6bda062d6a861071758ded8abc781af37a083e2/extensions/typescript-language-features/package.json#L1608-L1609)

this allows us to gather ALL code actions that are contributed, sorts by source actions, dynamically adds

demo with ruff and eslint installed:
Screenshot 2024-06-13 at 2 35 09 PM
Screenshot 2024-06-13 at 2 34 54 PM

cc. Michael Lively (@Yoyokrazy)

@justschen Justin Chen (justschen) changed the title language registry and code actions on save new filter intellisense for code actions on save Jun 13, 2024
@justschen

Copy link
Copy Markdown
Collaborator Author

Also as part of documentation, we could maybe note that if there are two of source actions of the same type, but one is a subset of another, only the larger subset would be honored (wording and terms can be better)

ie:

"editor.codeActionsOnSave": {
       "source.fixAll": "explicit",
       "source.fixAll.eslint": "never"

in this case, source.fixAll will override source.fixAll.eslint.

@mjbvz Matt Bierner (mjbvz) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good! I think you should also remove the static contribution tho. This was a proposal that I never actually finalized

One other thing to be aware of is that this intellisense will only pick up code actions for active languages. This at least ensures that only valid source actions are shown, but could also confuse users if they try configuring the setting without activating the language extension first (that's what the static contribution was trying to solve)

You could potentially solve this by caching the source actions for each extension across restarts. May be worth tracking in a new issue

@justschen
Justin Chen (justschen) marked this pull request as ready for review June 17, 2024 19:25
@vscodenpa VS Code Bot (vscodenpa) added this to the June 2024 milestone Jun 17, 2024
@justschen
Justin Chen (justschen) enabled auto-merge (squash) June 24, 2024 22:06
@justschen
Justin Chen (justschen) merged commit b7ff4c5 into microsoft:main Jun 24, 2024
Brice Friha (bricefriha) pushed a commit to bricefriha/vscode that referenced this pull request Jun 26, 2024
* language registry and code actions on save new filter

* fixes logic

* more clean up

* remove static contribution
Aaron (aaronchucarroll) pushed a commit to aaronchucarroll/vscode that referenced this pull request Jul 10, 2024
* language registry and code actions on save new filter

* fixes logic

* more clean up

* remove static contribution
@justschen
Justin Chen (justschen) deleted the justin/onsave branch August 8, 2024 21:47
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide better completion for editor.codeActionsOnSave

3 participants