Skip to content

Commit 148c19f

Browse files
author
Andrew Hall
authored
Do not remove documents if they are not files (#7607)
Fixes AB#2261836 When the preview changes window closes, it issues a document closed for a document being tracked but with a URI of 'vscode-bulkeditpreview-editor'. This is a valid notification for closing a document but it should not be removed because that will cause the content to be lost making the client and server out of sync for what it thinks the csharp/html code is
1 parent 6d39ad6 commit 148c19f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/razor/src/document/razorDocumentManager.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,13 @@ export class RazorDocumentManager implements IRazorDocumentManager {
193193
private closeDocument(uri: vscode.Uri) {
194194
const document = this._getDocument(uri);
195195

196-
// Files outside of the workspace will return undefined from getWorkspaceFolder
197-
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
198-
if (!workspaceFolder) {
199-
// Out of workspace files should be removed once they're closed
200-
this.removeDocument(uri);
196+
// Documents that are files should be removed if they are outside the workspace folder
197+
if (uri.scheme === 'file') {
198+
// Files outside of the workspace will return undefined from getWorkspaceFolder
199+
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
200+
if (!workspaceFolder) {
201+
this.removeDocument(uri);
202+
}
201203
}
202204

203205
this.notifyDocumentChange(document, RazorDocumentChangeKind.closed);

0 commit comments

Comments
 (0)