-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Provide API to retrieve or listen for registered document formatter IDs #135674
Comments
Is that your extension e2e? Iff so could know by exposing an API from you extension to those tests right? |
Added so that formatter test can wait until formatter is registered since VS Code has no API to check if a formatter with a given ID exists. See microsoft/vscode#135674
We didn't have an API yet, so I:
It definitely works, but it feels clunky having to add a notification to an editor-agnostic language server for testing purposes in a specific editor. I won't bikeshed, though, if an API endpoint for getting document formatters by ID or something similar to the same effect is not something y'all are interested in adding or accepting as a contribution. |
Yeah, it is that we don't have plans to expose such API - we try to keep it minimal and its purpose is to drive the editor itself, not so much be infrastructure. Given this is all e2e an easier approach might be simply self-activate your extension in tests (see |
Totally fair.
The extension is being activated in time — we have a global |
* refactor: Activate on `onStartupFinished` Closes #214 Stops this extension from slowing VS Code during startup. * feat: add API, formatter registration notification Added so that formatter test can wait until formatter is registered since VS Code has no API to check if a formatter with a given ID exists. See microsoft/vscode#135674 * docs: add entry to changelog
Issue Type: Feature Request
It'd be great to have a way in the VS Code API of retrieving which document formatters are currently registered or a notification for when a document formatter is registered.
Over at vscode-stylelint we have e2e tests that start up VS Code and test various extension features, one of which is document formatting. However, there doesn't seem to be a way to know for certain that document formatting has been registered before executing the test. As a result, while changing the extension's activation event from
*
toonStartupFinished
, the document formatter test has become flaky.In other tests, we are able to retrieve and wait on whatever it is we want tested, such as, for example, a command. However, the only instance I've been able to find of code that is able to the same or similar with document formatters is part of the private API. If something similar, whether notification- or polling-based, existed, it'd perfectly fit this use case.
If I've missed any similar API endpoints that are already in place, please feel free to let me know!
VS Code version: Code 1.61.2 (6cba118, 2021-10-19T14:57:20.575Z)
OS version: Windows_NT x64 10.0.22000
Restricted Mode: No
The text was updated successfully, but these errors were encountered: