I try to figure out, how to update a virtual document with my own custom Provider, which I have opened in an editor. I neither understand the docu at https://code.visualstudio.com/api/extension-guides/virtual-documents#update-virtual-documents nor the example at https://github.com/microsoft/vscode-extension-samples/tree/master/contentprovider-sample
I tried to hack something like the following:
class MyProvider implements vscode.TextDocumentContentProvider {
public onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>();
onDidChange = this.onDidChangeEmitter.event;
public static instance: LocalChangesProvider | undefined;
public constructor() {
LocalChangesProvider.instance = this;
}
provideTextDocumentContent(uri: vscode.Uri) {
return someGlobal.text;
}
}
someGlobal.text = 'other text';
MyProvider.instance.onDidChangeEmitter.fire(myUriSchema);
But it seems I am missing something. I am kind of frustrated, that I am too stupid to simply notify vscode to update my own virtual document :/ Any help is appreciated :)