Skip to content

Commit

Permalink
Fix some empty workspace edge cases on Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Oct 19, 2016
1 parent 30bb0b7 commit eb2a8e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/vs/code/electron-main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,9 @@ export class WindowsManager implements IWindowsService {
});
// Get rid of duplicates
iPathsToOpen = arrays.distinct(iPathsToOpen, path => {
if (!('workspacePath' in path)) {
return path.workspacePath;
}
return platform.isLinux ? path.workspacePath : path.workspacePath.toLowerCase();
});
}
Expand Down Expand Up @@ -764,8 +767,8 @@ export class WindowsManager implements IWindowsService {
// Emit events
iPathsToOpen.forEach(iPath => this.eventEmitter.emit(EventTypes.OPEN, iPath));

// Add to backups
this.backupService.pushWorkspaceBackupPathsSync(iPathsToOpen.map((path) => {
// Start tracking workspace backups
this.backupService.pushWorkspaceBackupPathsSync(iPathsToOpen.filter(path => 'workspacePath' in path).map(path => {
return Uri.file(path.workspacePath);
}));

Expand Down
8 changes: 6 additions & 2 deletions src/vs/workbench/services/textfile/browser/textFileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export abstract class TextFileService implements ITextFileService {

private beforeShutdown(): boolean | TPromise<boolean> {
// If hot exit is enabled then save the dirty files in the workspace and then exit
if (this.configuredHotExit) {
if (this.configuredHotExit && this.contextService.getWorkspace()) {
// If there are no dirty files, clean up and exit
if (this.getDirty().length === 0) {
return this.cleanupBackupsBeforeShutdown();
Expand Down Expand Up @@ -190,7 +190,11 @@ export abstract class TextFileService implements ITextFileService {
}

private cleanupBackupsBeforeShutdown(): boolean | TPromise<boolean> {
return this.backupService.removeWorkspaceBackupPath(this.contextService.getWorkspace().resource).then(() => {
const workspace = this.contextService.getWorkspace();
if (!workspace) {
return TPromise.as(false); // no backups to cleanup, no eto
}
return this.backupService.removeWorkspaceBackupPath(workspace.resource).then(() => {
return this.fileService.discardBackups().then(() => {
return false; // no veto
});
Expand Down

0 comments on commit eb2a8e1

Please sign in to comment.