Skip to content

Commit

Permalink
transient workspaces - do not add to workspaces history (#119695)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jun 24, 2021
1 parent 9587e96 commit a5dda82
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/vs/platform/windows/electron-main/windowsMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ interface IPathToOpen extends IPath {
// the workspace to open
readonly workspace?: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier;

// whether the path is considered to be transient or not
// for example, a transient workspace should not add to
// the workspaces history and should never restore
readonly transient?: boolean;

// the backup path to use
readonly backupPath?: string;

Expand Down Expand Up @@ -354,7 +359,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
if (!usedWindows.some(window => window.isExtensionDevelopmentHost) && !isDiff && !openConfig.noRecentEntry) {
const recents: IRecent[] = [];
for (const pathToOpen of pathsToOpen) {
if (isWorkspacePathToOpen(pathToOpen)) {
if (isWorkspacePathToOpen(pathToOpen) && !pathToOpen.transient /* never add transient workspaces to history */) {
recents.push({ label: pathToOpen.label, workspace: pathToOpen.workspace, remoteAuthority: pathToOpen.remoteAuthority });
} else if (isSingleFolderWorkspacePathToOpen(pathToOpen)) {
recents.push({ label: pathToOpen.label, folderUri: pathToOpen.workspace.uri, remoteAuthority: pathToOpen.remoteAuthority });
Expand Down Expand Up @@ -958,15 +963,12 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
if (workspace) {

// If the workspace is transient and we are to ignore
// transient workspaces, reject it. Also remove traces
// in the history if any.
// transient workspaces, reject it.
if (workspace.transient && options.rejectTransientWorkspaces) {
this.workspacesHistoryMainService.removeRecentlyOpened([URI.file(path)]);

return undefined;
}

return { workspace: { id: workspace.id, configPath: workspace.configPath }, remoteAuthority: workspace.remoteAuthority, exists: true };
return { workspace: { id: workspace.id, configPath: workspace.configPath }, remoteAuthority: workspace.remoteAuthority, exists: true, transient: workspace.transient };
}
}

Expand Down

0 comments on commit a5dda82

Please sign in to comment.