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

vscode.TextDocumentContentProvider providers don't get updated as extensions get activated. #211116

Open
gcampbell-msft opened this issue Apr 23, 2024 · 4 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@gcampbell-msft
Copy link

gcampbell-msft commented Apr 23, 2024

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.88.1
  • OS Version: Windows 11

Steps to Reproduce:

Follow the repro steps for this bug: microsoft/vscode-cmake-tools#3651. This is the root bug that I was investigating that caused me to create this.

I think I've noticed the issue.

Effectively, if you open the folder WITHOUT the CMakePresets.json file open. Then, perform an action that activates the CMake Tools extension, THEN open up the CMakePresets.json file, since the provider is already activated, the provideTextDocumentContent method that the CMake Tools extension provides will get called.

However, if you open the CMakePresets.json file BEFORE the CMake Tools extension is activated, even after activating the CMake Tools extension and closing an reopening the CMakePresets.json file, the validation still fails.

This makes me think that the provideTextDocumentContent isn't being called again for new providers when extensions are activated.

Technically we could fix this by adding an onFileSystem:cmake-tools-schema activationEvent, but I'm not sure yet whether we want to do this.

Thanks

@jrieken
Copy link
Member

jrieken commented Apr 23, 2024

Follow the repro steps for this bug: microsoft/vscode-cmake-tools#3651. This is the root bug that I was investigating that caused me to create this.

Sorry, I cannot go through that. Minimal repro steps welcome.

This makes me think that the provideTextDocumentContent isn't being called again for new providers when extensions are activated.

Can you provide more context? Is the CMakePresets.json-file a real file on disk or where does it come from? Also, who is provide its contents in case your extension hasn't been activated yet.

Generally, "yes" we don't call provideTextDocumentContent again if the document is already open and "owned" by another provider

@jrieken jrieken added the info-needed Issue requires more information from poster label Apr 23, 2024
@gcampbell-msft
Copy link
Author

@jrieken CMakePresets.json is a real file.
My expectation is that it wouldn't be owned by another provider except for when our extension is activated.

Minimal repro steps:

  1. Open an empty folder
  2. Ensure the CMake Tools extension is installed.
  3. Create a CMakePresets.json file with the contents of "{}".
  4. Notice that there is a warning at the top saying it couldn't load the schema.
  5. Run the "CMake: Configure" command to activate the cmake tools extension.
  6. The schema issue doesn't go away even though it's activated now.

This is where I would slightly expect that when we provide the schema provider, it would get re-called and it would resolve.

To see how our extension does provide the schema:

  1. In the same project as above, close the CMakePresets.json file.
  2. Close VS Code.
  3. Open VS Code.
  4. Run "CMake: Configure" command to activate CMake Tools extension.
  5. Open CMakePresets.json
  6. Notice that schema is correctly loaded.

@jrieken
Copy link
Member

jrieken commented Apr 23, 2024

Notice that there is a warning at the top saying it couldn't load the schema.

So, you register a text document content provider for the schema, not for the file itself. But the schema-uri is passed through some other way, right?

@gcampbell-msft
Copy link
Author

Correct.

I'm not 100% sure I understand your question. But the CMake Tools extension uses the package.json jsonValidation entry to associate the files with the schema-uri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants