mechatroner/vscode_rainbow_csv

Rainbow CSV Doesn't check for document scheme before execution

Closed this issue · 3 comments

I'm working on a PR for another extension that uses Virtual Documents to display content: https://code.visualstudio.com/api/extension-guides/virtual-documents

The extension has its own formatting/coloring rules and expects to be able to update this content after it is displayed. However, Rainbow CSV sees that the content is in a CSV-like format and reloads the document on its own. My extension sees the onDidCloseTextDocument event caused by Rainbow CSV, and it disposes its references, thinking the user closed the tab.

I'm using a custom document scheme to keep my virtual documents separate, but that is not checked by Rainbow CSV before it tries to format. Could you please add a check so that only files opened by the user are processed, and not those created by other extensions?

As per the VSCode documentation:

Events and Visibility
Document providers are first class citizens in VS Code, their contents appears in regular text documents, they use the same infrastructure as files etc. However, that also means that "your" documents cannot hide, they will appear in onDidOpenTextDocument and onDidCloseTextDocument-events, they are part of vscode.workspace.textDocuments and more. The rule for everyone is check the scheme of documents and then decide if you want to do something with/for the document.

Thanks for the bug report!
I made a patch and will try to publish the updated version soon.

Great - thanks so much for the fast response.

I just published version 3.4.0 which contains the fix.
Please let me know if it still doesn't work as expected.