Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98538

vscode-extension update virtual document

$
0
0

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 :)


Viewing all articles
Browse latest Browse all 98538

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>