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

Multiple formatters from the same extension cause choices for default formatter to be not helpful #72315

Closed
ramya-rao-a opened this issue Apr 15, 2019 · 6 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@ramya-rao-a
Copy link
Contributor

The vscode-go extension gives language server support for the user to opt-in to.
Using settings, we allow user to pick and choose the features they would want to use language server for.

For example, a user can choose to use the language server, but choose not to use its formatting features.

The way we accomplish this is by having the extension register a formatting provider and use middleware to ignore formatting results from language server.

This results in 2 formatters for the extension. VS Code prompts the user to select the default formatter which results in the below:

Screen Shot 2019-04-14 at 11 05 18 PM

It confuses users to see both options with the same name.
If they choose the one that is meant for language server, then they won't get any formatting edits.

Proposed solution:
If one of the registered providers returns empty results, do not consider it as one of the multiple formatters and thus avoid the prompt to select the default provider.

@jrieken
Copy link
Member

jrieken commented Apr 15, 2019

extension register a formatting provider and use middleware to ignore formatting results from language server.

That's the problem, you should not register two providers and ignore one because that's not how the integration works. Calling register does something, like updating the UI et al, and that's nothing to be toyed with. Your proposed solution doesn't work because the picker comes before calling a formatter.

You extension should have default values and honour that, e.g register formatter A only, on setting change unregister A, register B etc

@jrieken jrieken added the *as-designed Described behavior is as designed label Apr 15, 2019
@vscodebot
Copy link

vscodebot bot commented Apr 15, 2019

The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Apr 15, 2019
@ramya-rao-a
Copy link
Contributor Author

Thanks @jrieken

To unregister a registered provider, do we just call dispose on what is returned by the vscode.languages.register....Provider() ?

@jrieken
Copy link
Member

jrieken commented Apr 16, 2019

yes, dispose is all you need

@ramya-rao-a
Copy link
Contributor Author

And is there a way to unregister the provider from the language server?

@jrieken
Copy link
Member

jrieken commented Apr 17, 2019

sure, see this: #70314 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

2 participants