-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Code actions contribution point #82718
Comments
This comment has been minimized.
This comment has been minimized.
I have checked in a prototype of the static @jrieken brought up that not all extensions may be able to generate these lists ahead of time, such as those using Rosyln. For some use cases, we may also want to dynamically enabled/disable which code actions are shown to the user. If you are using an old TypeScript version for example, refactoring is not supported. An example of where code actions would be enabled/disabled would a improved My current thinking on static vs dynamic contribution points is that we likely want both:
|
This comment has been minimized.
This comment has been minimized.
Copying a few extension authors for feedback on contribution point and possible use cases @DanTup for Dart |
- Adds a description - Remove schama - Moves the language to the top level so we don't need to duplicate so much info for each code action
Based on trying this for JS/TS, I've added a "codeActions": [
{
"languages": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"actions": [
{
"kind": "refactor.extract.constant",
"title": "%codeActions.refactor.extract.constant.title%",
"description": "%codeActions.refactor.extract.constant.description%"
},
....
]
}
] |
Are these code actions context aware (visa a callback)? |
This proposal does not effect the existing |
Missed this. |
The code actions in Dart are all defined in the language server, so we can't really provide this ahead-of-time either. This is similar to a request I made a while ago for keybinds: I expected them to only show up when the extension is activated though - not ideal, but supports the case where they might change across different versions of SDKs that you can't possibly know ahead-of-time. |
@mjbvz Maybe something more pragmatic. Once a code action provider registered (dynamically) we store its code action kinds (for configurations) and revalidate them whenever registration happens again or when an extension cannot be found anymore. That would work better with dynamic code action lists and still yield in a better user experience - except the first time before the first activation. |
@DanTup This is the case for TS as well. There should be some way for you to extract this list, either manually or with automation. Again the idea is that the extension provides the complete set of all possible refactorings that users can configure—regardless of what specific language version a user is on—and that this does not any impact on what actions are actually shown in the editor I'm not opposed to allowing the same metadata to be contributed dynamically as well, but this would also be new information that extensions would have to provide to VS Code (i.e. through a new api). The current @jrieken Managing a cache of metadata about code actions will get very complicated. TS for example only contributes a refactor provider if you are using TS 2.8, and user can explicitly disable some code actions like organize imports through settings |
Sure, it just means having some script to update/maintain it I was hoping to avoid :-)
Doesn't that affect a static list in the same way (there may be things in the static list that have been disabled)? |
I made a script which generates all of TypeScripts microsoft/TypeScript#34859 (comment) , but the tricky thing here is that it won't account for a workspace's version of typescript (only vscode's) - which could end up asking for refactors that don't exist. That could end up being a tricky mismatch. We wondered about making it something the TSServer could provide? but that kinda undermines the point of having it beforehand. |
Yes, but applying the same logic how it is then better to "cache" them at compile time, e.g writing them upfront into package.json without knowing anything about the user or her/his settings nor being able to change that list? What I am suggesting is to cache them only between the time of deactivation and activation. |
In our existing keybindings UX, we let users configure keybindings for any command. Many of these commands are only actually enabled when the user has enabled a setting or switched their language run time, but that does not prevent users from setting up the keybinding. I believe that is also the behavior we want when configure keybindings for code actions or refactors: I should always be able to configure a keybinding for |
(oh, ignoring the warning seems like the right thing - my code action then shows up! 🤨) |
Pylance team wants to expose all individuals I think that makes it very hard for users to discover each Please, provide a way to configure this by each |
We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider. If you wonder what we are up to, please see our roadmap and issue reporting guidelines. Thanks for your understanding, and happy coding! |
Problem
For feature requests such as #52846 or any improved refactoring UX, VS Code needs to know all the code actions that are available for a language. Some information about available code actions is provided by
CodeActionProviderMetadata
but only if an extension has been activated and the provider has been registeredProposal
To support this, we likely want a new contribution point that lets extensions statically tell us about the general classes of the code actions that they provide:
Potential use cases for this info
codeActionsOnSave
(c8d64b1)/cc @kieferrm
The text was updated successfully, but these errors were encountered: