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

Should editor consider code actions that are not listed in codeActionKinds? #1629

Open
rchl opened this issue Dec 30, 2022 · 5 comments
Open
Labels
clarification *question Issue represents a question, should be posted to StackOverflow (VS Code)
Milestone

Comments

@rchl
Copy link
Contributor

rchl commented Dec 30, 2022

Server can specify code actions that it supports through the codeActionProvider.codeActionKinds server capability. The spec says this about it:

	/**
	 * CodeActionKinds that this server may return.
	 *
	 * The list of kinds may be generic, such as `CodeActionKind.Refactor`,
	 * or the server may list out every specific kind they provide.
	 */
	codeActionKinds?: CodeActionKind[];

My questions are:

  • Should editor only allow code actions specified in codeActionProvider.codeActionKinds to be run as part of the "code actions on save" functionality? I know that "Code actions on save" are not really part of the spec but maybe you have opinion as someone who works with the "reference implementation" (VSCode).
  • Besides "code actions on save", what was the thinking behind introducing this capability? What practical effect should it have on the client from the LSP perspective?
@dbaeumer
Copy link
Member

Regarding

Besides "code actions on save", what was the thinking behind introducing this capability? What practical effect should it have on the client from the LSP perspective?

To avoid asking the server for code actions if they are not providing code actions for a specific kind.

For code actions on save: the client will ask with a specific kind for code actions on save. The kind is CodeActionKind.SourceFixAll

Hope that answers your questions.

@rchl
Copy link
Contributor Author

rchl commented Jul 23, 2024

I believe the first part of the question wasn't answered:

Should editor only allow code actions specified in codeActionProvider.codeActionKinds to be run as part of the "code actions on save" functionality?

@dbaeumer
Copy link
Member

dbaeumer commented Aug 5, 2024

When the editor is asking for code actions on save the code action kind should be CodeActionKind.Source.FixAll or a subkind of it. If the server has not registered for that kind the editor shouldn't ask the server for code actions on save (see https://github.com/microsoft/vscode-eslint/blob/main/server/src/eslintServer.ts#L224 as an example)

@rchl
Copy link
Contributor Author

rchl commented Aug 5, 2024

Would you add something to that effect to the spec?

Note that VSCode doesn't follow that currently and will ask for code actions on save even if those are not registered through codeActionProvider.codeActionKinds server capability.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 5, 2024

Note that VSCode doesn't follow that currently and will ask for code actions on save even if those are not registered through codeActionProvider.codeActionKinds server capability.

Good point and this is not only VS Code. We need to keep this for backwards compatibility since code actions on save where there before we add the kind registration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification *question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants