File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,20 @@ export class HtmlDocumentManager {
25
25
26
26
public register ( ) {
27
27
const didCloseRegistration = vscode . workspace . onDidCloseTextDocument ( async ( document ) => {
28
- if ( document . languageId !== 'html' ) {
28
+ // We log when a virtual document is closed just in case it helps track down future bugs
29
+ if ( document . uri . scheme === HtmlDocumentContentProvider . scheme ) {
30
+ this . logger . logVerbose ( `Virtual document '${ document . uri } ' timed out.` ) ;
29
31
return ;
30
32
}
31
33
32
- await this . closeDocument ( document . uri ) ;
34
+ // When a Razor document is closed, only then can we be sure its okay to remove the virtual document.
35
+ if ( document . languageId === 'aspnetcorerazor' ) {
36
+ this . logger . logVerbose ( `Document '${ document . uri } ' was closed.` ) ;
37
+
38
+ await this . closeDocument ( document . uri ) ;
39
+
40
+ // TODO: Send a notification back to the server so it can cancel any pending sync requests and clear its cache.
41
+ }
33
42
} ) ;
34
43
35
44
const providerRegistration = vscode . workspace . registerTextDocumentContentProvider (
@@ -51,10 +60,10 @@ export class HtmlDocumentManager {
51
60
}
52
61
53
62
private async closeDocument ( uri : vscode . Uri ) {
54
- const document = await this . getDocument ( uri ) ;
63
+ const document = await this . findDocument ( uri ) ;
55
64
56
65
if ( document ) {
57
- this . logger . logVerbose ( `Document '${ document . uri } ' was closed. Removing from the document manager.` ) ;
66
+ this . logger . logVerbose ( `Removing '${ document . uri } ' from the document manager.` ) ;
58
67
59
68
delete this . htmlDocuments [ document . path ] ;
60
69
}
You can’t perform that action at this time.
0 commit comments