Skip to content

Conversation

@spahnke
Copy link
Contributor

@spahnke spahnke commented Aug 20, 2021

This PR fixes microsoft/monaco-editor#2625

Added a third optional parameter metadata on registerCodeActionProvider the same way the VS Code extension API does it, so that embedders of the Monaco editor can list the provided code action kinds and get support for the editor.action.autoFix action, as well as the "Refactor..." and "Source Action..." context menu entries. I copied over the type CodeActionProviderMetadata from vscode.d.ts into monaco.d.ts and just kept the providedCodeActionKinds property, adjusting the type and documentation wording accordingly.

* Register a code action provider (used by e.g. quick fix).
*/
export function registerCodeActionProvider(languageId: string, provider: CodeActionProvider): IDisposable;
export function registerCodeActionProvider(languageId: string, provider: CodeActionProvider, metadata?: CodeActionProviderMetadata): IDisposable;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added these by hand, but I'm unsure if there is a generation process of this file involved somewhere. Or is it only the final monaco.d.ts that's shipped with the NPM package that's generated from this one?

Copy link
Member

Choose a reason for hiding this comment

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

I think it is being generated, but the outcome would be the same.

Copy link

@Omichaelking Omichaelking left a comment

Choose a reason for hiding this comment

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

Okay

@hediet hediet added this to the August 2021 milestone Aug 22, 2021
@hediet
Copy link
Member

hediet commented Aug 24, 2021

Thank you for your PR!

@hediet hediet merged commit e0c5a9c into microsoft:main Aug 24, 2021
@spahnke spahnke deleted the monaco-code-action branch August 24, 2021 12:18
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2021
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.

Add ability to specify the provided code action kinds from a CodeActionProvider

3 participants