Skip to content

Commit

Permalink
Do not remove documents if they are not files (#7607)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ryzngard authored Sep 26, 2024
1 parent 6d39ad6 commit 148c19f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/razor/src/document/razorDocumentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ export class RazorDocumentManager implements IRazorDocumentManager {
private closeDocument(uri: vscode.Uri) {
const document = this._getDocument(uri);

// Files outside of the workspace will return undefined from getWorkspaceFolder
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
if (!workspaceFolder) {
// Out of workspace files should be removed once they're closed
this.removeDocument(uri);
// Documents that are files should be removed if they are outside the workspace folder
if (uri.scheme === 'file') {
// Files outside of the workspace will return undefined from getWorkspaceFolder
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
if (!workspaceFolder) {
this.removeDocument(uri);
}
}

this.notifyDocumentChange(document, RazorDocumentChangeKind.closed);
Expand Down

0 comments on commit 148c19f

Please sign in to comment.