I'm working on Visual Studio Code extension and I need to detect when some document window is closed. I know about vscode.workspace.onDidCloseTextDocument event and it works at general.
But if I open a file from the workspace via API:
vscode.workspace.openTextDocument(localPath).then(function (doc) {
vscode.window.showTextDocument(doc, 1);
});
and then close it, the onDidCloseTextDocument doesn't fire as usual. Its fire but few minutes later.
I know if this is some bug or this is the way VSCode works but I need to know how to detect when document window is closed.
I was reading that opening file via API is some kind of "virtual" file. So, probably this cause the problem.