Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edit session view preview of empty added files #158040

Merged
merged 1 commit into from Aug 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,7 +7,7 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Event } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { FilePermission, FileSystemProviderCapabilities, FileSystemProviderErrorCode, FileType, IFileDeleteOptions, IFileOverwriteOptions, IFileSystemProviderWithFileReadCapability, IStat, IWatchOptions } from 'vs/platform/files/common/files';
import { decodeEditSessionFileContent, EDIT_SESSIONS_SCHEME, IEditSessionsWorkbenchService } from 'vs/workbench/contrib/editSessions/common/editSessions';
import { ChangeType, decodeEditSessionFileContent, EDIT_SESSIONS_SCHEME, IEditSessionsWorkbenchService } from 'vs/workbench/contrib/editSessions/common/editSessions';

export class EditSessionsFileSystemProvider implements IFileSystemProviderWithFileReadCapability {

Expand All @@ -29,11 +29,11 @@ export class EditSessionsFileSystemProvider implements IFileSystemProviderWithFi
if (!data) {
throw FileSystemProviderErrorCode.FileNotFound;
}
const content = data?.editSession.folders.find((f) => f.name === folderName)?.workingChanges.find((change) => change.relativeFilePath === filePath)?.contents;
if (!content) {
const change = data?.editSession.folders.find((f) => f.name === folderName)?.workingChanges.find((change) => change.relativeFilePath === filePath);
if (!change || change.type === ChangeType.Deletion) {
throw FileSystemProviderErrorCode.FileNotFound;
}
return decodeEditSessionFileContent(data.editSession.version, content).buffer;
return decodeEditSessionFileContent(data.editSession.version, change.contents).buffer;
}

async stat(resource: URI): Promise<IStat> {
Expand Down