I can't find any clear documentation around this so I'm hoping someone might know the answer. Is the vscode editor.codeActionsOnSave
setting able to point to arbitrary commands that are defined by vscode extensions, or can you only use things like source.organizeImports
? I'm trying to run a command from an extension that works when triggered via a keyboard shortcut (in this case, vsSharper.sortUsings
), but when I add either
"editor.codeActionsOnSave": [ "vsSharper.sortUsings" ]
or
"editor.codeActionsOnSave": {
"vsSharper.sortUsings": "always"
}
to my settings.json the command isn't run and my using statements are not sorted by the extension. I do not understand why though, since this other extension's documentation seems to indicate this should be possible (this setting being pointed to an extension's command): https://biomejs.dev/reference/vscode/#fix-on-save
Which "commands" can be executed via editor.codeActionsOnSave?
None. Code Actions and Commands are two different things. Unless an exanetion implementor makes the implementation of a code action do the same thing as a command / invoke a command.
For the extension-implementor, some of the related APIs are CodeActionProvider<T>
and registerCommand
.
If you want to know what code actions an extension provides, check its docs. If they're not documented, you could potentially find info about it by reading the source code, but since the provider can do whatever it wants (Ex. make JS-external calls, such as to a program binary without debug info), you could also run out of luck with that. Try also triggering suggestions in the body of editor.codeActionsOnSave
in settings.json.