diff --git a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts index 611a5d77b5..1a7b38cf61 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts @@ -19,8 +19,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { IStateMainService } from 'vs/platform/state/electron-main/state'; -import { ICodeWindow } from 'vs/platform/windows/electron-main/windows'; -import { IRecent, IRecentFile, IRecentFolder, IRecentlyOpened, IRecentWorkspace, isRecentFile, isRecentFolder, isRecentWorkspace, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, IWorkspaceIdentifier, RecentlyOpenedStorageData, restoreRecentlyOpened, toStoreData, WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; +import { IRecent, IRecentFile, IRecentFolder, IRecentlyOpened, IRecentWorkspace, isRecentFile, isRecentFolder, isRecentWorkspace, IWorkspaceIdentifier, RecentlyOpenedStorageData, restoreRecentlyOpened, toStoreData, WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService'; export const IWorkspacesHistoryMainService = createDecorator('workspacesHistoryMainService'); @@ -32,7 +31,7 @@ export interface IWorkspacesHistoryMainService { readonly onDidChangeRecentlyOpened: CommonEvent; addRecentlyOpened(recents: IRecent[]): void; - getRecentlyOpened(include?: ICodeWindow): IRecentlyOpened; + getRecentlyOpened(): IRecentlyOpened; removeRecentlyOpened(paths: URI[]): void; clearRecentlyOpened(): void; @@ -241,29 +240,10 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa this._onDidChangeRecentlyOpened.fire(); } - getRecentlyOpened(include?: ICodeWindow): IRecentlyOpened { + getRecentlyOpened(): IRecentlyOpened { const workspaces: Array = []; const files: IRecentFile[] = []; - // Add current workspace to beginning if set - const currentWorkspace = include?.config?.workspace; - if (isWorkspaceIdentifier(currentWorkspace) && !this.workspacesManagementMainService.isUntitledWorkspace(currentWorkspace)) { - workspaces.push({ workspace: currentWorkspace }); - } else if (isSingleFolderWorkspaceIdentifier(currentWorkspace)) { - workspaces.push({ folderUri: currentWorkspace.uri }); - } - - // Add currently files to open to the beginning if any - const currentFiles = include?.config?.filesToOpenOrCreate; - if (currentFiles) { - for (let currentFile of currentFiles) { - const fileUri = currentFile.fileUri; - if (fileUri && this.indexOfFile(files, fileUri) === -1) { - files.push({ fileUri }); - } - } - } - this.addEntriesFromStorage(workspaces, files); return { workspaces, files }; diff --git a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts index 283f3252f0..1f9837f358 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts @@ -53,7 +53,7 @@ export class WorkspacesMainService implements AddFirstParameterToFunctions { - return this.workspacesHistoryMainService.getRecentlyOpened(this.windowsMainService.getWindowById(windowId)); + return this.workspacesHistoryMainService.getRecentlyOpened(); } async addRecentlyOpened(windowId: number, recents: IRecent[]): Promise { diff --git a/src/vs/workbench/browser/dnd.ts b/src/vs/workbench/browser/dnd.ts index 0cb05f111e..c784eadf75 100644 --- a/src/vs/workbench/browser/dnd.ts +++ b/src/vs/workbench/browser/dnd.ts @@ -31,7 +31,6 @@ import { Emitter } from 'vs/base/common/event'; import { coalesce } from 'vs/base/common/arrays'; import { parse, stringify } from 'vs/base/common/marshalling'; import { ILabelService } from 'vs/platform/label/common/label'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { withNullAsUndefined } from 'vs/base/common/types'; //#region Editor / Resources DND @@ -190,8 +189,7 @@ export class ResourcesDropHandler { @IWorkspacesService private readonly workspacesService: IWorkspacesService, @IEditorService private readonly editorService: IEditorService, @IWorkspaceEditingService private readonly workspaceEditingService: IWorkspaceEditingService, - @IHostService private readonly hostService: IHostService, - @IWorkspaceContextService private readonly contextService: IWorkspaceContextService + @IHostService private readonly hostService: IHostService ) { } @@ -216,12 +214,8 @@ export class ResourcesDropHandler { } // Add external ones to recently open list unless dropped resource is a workspace - // and only for resources that are outside of the currently opened workspace if (externalLocalFiles.length) { - this.workspacesService.addRecentlyOpened(externalLocalFiles - .filter(resource => !this.contextService.isInsideWorkspace(resource)) - .map(resource => ({ fileUri: resource })) - ); + this.workspacesService.addRecentlyOpened(externalLocalFiles.map(resource => ({ fileUri: resource }))); } // Open in Editor diff --git a/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts b/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts index f1fa5a69ec..1ffdabaefa 100644 --- a/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts +++ b/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts @@ -193,12 +193,8 @@ export abstract class AbstractFileDialogService implements IFileDialogService { } } - private addFileToRecentlyOpened(uri: URI): void { - // add the picked file into the list of recently opened - // only if it is outside the currently opened workspace - if (!this.contextService.isInsideWorkspace(uri)) { - this.workspacesService.addRecentlyOpened([{ fileUri: uri, label: this.labelService.getUriLabel(uri) }]); - } + protected addFileToRecentlyOpened(uri: URI): void { + this.workspacesService.addRecentlyOpened([{ fileUri: uri, label: this.labelService.getUriLabel(uri) }]); } protected async pickFolderAndOpenSimplified(schema: string, options: IPickAndOpenOptions): Promise { @@ -228,7 +224,13 @@ export abstract class AbstractFileDialogService implements IFileDialogService { } options.title = nls.localize('saveFileAs.title', 'Save As'); - return this.saveRemoteResource(options); + const uri = await this.saveRemoteResource(options); + + if (uri) { + this.addFileToRecentlyOpened(uri); + } + + return uri; } protected async showSaveDialogSimplified(schema: string, options: ISaveDialogOptions): Promise { diff --git a/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts b/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts index 626ff8ec41..7969be4f71 100644 --- a/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts +++ b/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts @@ -131,7 +131,11 @@ export class FileDialogService extends AbstractFileDialogService implements IFil } else { const result = await this.nativeHostService.showSaveDialog(this.toNativeSaveDialogOptions(options)); if (result && !result.canceled && result.filePath) { - return URI.file(result.filePath); + const uri = URI.file(result.filePath); + + this.addFileToRecentlyOpened(uri); + + return uri; } } return undefined; // {{SQL CARBON EDIT}} strict-null-check