@@ -24,9 +24,9 @@ import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
2424import product from 'vs/platform/product/node/product' ;
2525import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
2626import { IWindowsMainService , IOpenConfiguration , IWindowsCountChangedEvent , ICodeWindow , IWindowState as ISingleWindowState , WindowMode } from 'vs/platform/windows/electron-main/windows' ;
27- import { IHistoryMainService } from 'vs/platform/history/common/history' ;
27+ import { IHistoryMainService , IRecent } from 'vs/platform/history/common/history' ;
2828import { IProcessEnvironment , isMacintosh , isWindows } from 'vs/base/common/platform' ;
29- import { IWorkspacesMainService , IWorkspaceIdentifier , WORKSPACE_FILTER , ISingleFolderWorkspaceIdentifier , isSingleFolderWorkspaceIdentifier , hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces' ;
29+ import { IWorkspacesMainService , IWorkspaceIdentifier , WORKSPACE_FILTER , isSingleFolderWorkspaceIdentifier , hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces' ;
3030import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
3131import { mnemonicButtonLabel } from 'vs/base/common/labels' ;
3232import { Schemas } from 'vs/base/common/network' ;
@@ -37,6 +37,7 @@ import { exists } from 'vs/base/node/pfs';
3737import { getComparisonKey , isEqual , normalizePath , basename as resourcesBasename , originalFSPath , hasTrailingPathSeparator , removeTrailingPathSeparator } from 'vs/base/common/resources' ;
3838import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts' ;
3939import { restoreWindowsState , WindowsStateStorageData , getWindowsStateStoreData } from 'vs/code/electron-main/windowsStateStorage' ;
40+ import { getWorkspaceIdentifier } from 'vs/platform/workspaces/electron-main/workspacesMainService' ;
4041
4142const enum WindowError {
4243 UNRESPONSIVE = 1 ,
@@ -114,6 +115,9 @@ interface IPathToOpen extends IPath {
114115
115116 // indicator to create the file path in the Code instance
116117 createFilePath ?: boolean ;
118+
119+ // optional label for the recent history
120+ label ?: string ;
117121}
118122
119123function isFolderPathToOpen ( path : IPathToOpen ) : path is IFolderPathToOpen {
@@ -130,6 +134,9 @@ interface IFolderPathToOpen {
130134
131135 // the remote authority for the Code instance to open. Undefined if not remote.
132136 remoteAuthority ?: string ;
137+
138+ // optional label for the recent history
139+ label ?: string ;
133140}
134141
135142function isWorkspacePathToOpen ( path : IPathToOpen ) : path is IWorkspacePathToOpen {
@@ -146,6 +153,9 @@ interface IWorkspacePathToOpen {
146153
147154 // the remote authority for the Code instance to open. Undefined if not remote.
148155 remoteAuthority ?: string ;
156+
157+ // optional label for the recent history
158+ label ?: string ;
149159}
150160
151161export class WindowsManager implements IWindowsMainService {
@@ -479,23 +489,18 @@ export class WindowsManager implements IWindowsMainService {
479489
480490 // Remember in recent document list (unless this opens for extension development)
481491 // Also do not add paths when files are opened for diffing, only if opened individually
482- if ( ! usedWindows . some ( w => w . isExtensionDevelopmentHost ) && ! openConfig . diffMode ) {
483- const recentlyOpenedWorkspaces : Array < IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier > = [ ] ;
484- const recentlyOpenedFiles : URI [ ] = [ ] ;
485-
486- pathsToOpen . forEach ( win => {
487- if ( win . workspace ) {
488- recentlyOpenedWorkspaces . push ( win . workspace ) ;
489- } else if ( win . folderUri ) {
490- recentlyOpenedWorkspaces . push ( win . folderUri ) ;
491- } else if ( win . fileUri ) {
492- recentlyOpenedFiles . push ( win . fileUri ) ;
492+ if ( ! usedWindows . some ( w => w . isExtensionDevelopmentHost ) && ! openConfig . diffMode && ! this . environmentService . skipAddToRecentlyOpened ) {
493+ const recents : IRecent [ ] = [ ] ;
494+ for ( let pathToOpen of pathsToOpen ) {
495+ if ( pathToOpen . workspace ) {
496+ recents . push ( { label : pathToOpen . label , workspace : pathToOpen . workspace } ) ;
497+ } else if ( pathToOpen . folderUri ) {
498+ recents . push ( { label : pathToOpen . label , folderUri : pathToOpen . folderUri } ) ;
499+ } else if ( pathToOpen . fileUri ) {
500+ recents . push ( { label : pathToOpen . label , fileUri : pathToOpen . fileUri } ) ;
493501 }
494- } ) ;
495-
496- if ( ! this . environmentService . skipAddToRecentlyOpened ) {
497- this . historyMainService . addRecentlyOpened ( recentlyOpenedWorkspaces , recentlyOpenedFiles ) ;
498502 }
503+ this . historyMainService . addRecentlyOpened ( recents ) ;
499504 }
500505
501506 // If we got started with --wait from the CLI, we need to signal to the outside when the window
@@ -844,6 +849,7 @@ export class WindowsManager implements IWindowsMainService {
844849
845850 const path = this . parseUri ( pathToOpen . uri , pathToOpen . typeHint , parseOptions ) ;
846851 if ( path ) {
852+ path . label = pathToOpen . label ;
847853 pathsToOpen . push ( path ) ;
848854 } else {
849855
@@ -1031,7 +1037,7 @@ export class WindowsManager implements IWindowsMainService {
10311037 }
10321038 if ( hasWorkspaceFileExtension ( uri . path ) && ! options . forceOpenWorkspaceAsFile ) {
10331039 return {
1034- workspace : this . workspacesMainService . getWorkspaceIdentifier ( uri ) ,
1040+ workspace : getWorkspaceIdentifier ( uri ) ,
10351041 remoteAuthority
10361042 } ;
10371043 }
@@ -1098,9 +1104,8 @@ export class WindowsManager implements IWindowsMainService {
10981104 }
10991105 }
11001106 } catch ( error ) {
1101- this . historyMainService . removeFromRecentlyOpened ( [ candidate ] ) ; // since file does not seem to exist anymore, remove from recent
1102-
11031107 const fileUri = URI . file ( candidate ) ;
1108+ this . historyMainService . removeFromRecentlyOpened ( [ fileUri ] ) ; // since file does not seem to exist anymore, remove from recent
11041109 if ( options && options . ignoreFileNotFound ) {
11051110 return { fileUri, createFilePath : true , remoteAuthority } ; // assume this is a file that does not yet exist
11061111 }
@@ -1513,7 +1518,7 @@ export class WindowsManager implements IWindowsMainService {
15131518 private doEnterWorkspace ( win : ICodeWindow , result : IEnterWorkspaceResult ) : IEnterWorkspaceResult {
15141519
15151520 // Mark as recently opened
1516- this . historyMainService . addRecentlyOpened ( [ result . workspace ] , [ ] ) ;
1521+ this . historyMainService . addRecentlyOpened ( [ { workspace : result . workspace } ] ) ;
15171522
15181523 // Trigger Eevent to indicate load of workspace into window
15191524 this . _onWindowReady . fire ( win ) ;
@@ -1968,7 +1973,7 @@ class WorkspacesManager {
19681973 if ( ! isValid ) {
19691974 return null ; // return early if the workspace is not valid
19701975 }
1971- const workspaceIdentifier = this . workspacesMainService . getWorkspaceIdentifier ( path ) ;
1976+ const workspaceIdentifier = getWorkspaceIdentifier ( path ) ;
19721977 return this . doOpenWorkspace ( window , workspaceIdentifier ) ;
19731978 } ) ;
19741979
@@ -1984,7 +1989,7 @@ class WorkspacesManager {
19841989 }
19851990
19861991 // Prevent overwriting a workspace that is currently opened in another window
1987- if ( findWindowOnWorkspace ( this . windowsMainService . getWindows ( ) , this . workspacesMainService . getWorkspaceIdentifier ( path ) ) ) {
1992+ if ( findWindowOnWorkspace ( this . windowsMainService . getWindows ( ) , getWorkspaceIdentifier ( path ) ) ) {
19881993 const options : Electron . MessageBoxOptions = {
19891994 title : product . nameLong ,
19901995 type : 'info' ,
0 commit comments