44 *--------------------------------------------------------------------------------------------*/
55
66import * as nls from 'vs/nls' ;
7- import { IWindowOpenable } from 'vs/platform/windows/common/windows' ;
7+ import { IWindowOpenable , isWorkspaceToOpen , isFileToOpen } from 'vs/platform/windows/common/windows' ;
88import { IPickAndOpenOptions , ISaveDialogOptions , IOpenDialogOptions , FileFilter , IFileDialogService , IDialogService , ConfirmResult , getFileNamesMessage } from 'vs/platform/dialogs/common/dialogs' ;
99import { IWorkspaceContextService , WorkbenchState } from 'vs/platform/workspace/common/workspace' ;
1010import { IHistoryService } from 'vs/workbench/services/history/common/history' ;
@@ -14,7 +14,7 @@ import { Schemas } from 'vs/base/common/network';
1414import * as resources from 'vs/base/common/resources' ;
1515import { IInstantiationService , } from 'vs/platform/instantiation/common/instantiation' ;
1616import { SimpleFileDialog } from 'vs/workbench/services/dialogs/browser/simpleFileDialog' ;
17- import { WORKSPACE_EXTENSION , isUntitledWorkspace } from 'vs/platform/workspaces/common/workspaces' ;
17+ import { WORKSPACE_EXTENSION , isUntitledWorkspace , IWorkspacesService } from 'vs/platform/workspaces/common/workspaces' ;
1818import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts' ;
1919import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
2020import { IFileService } from 'vs/platform/files/common/files' ;
@@ -24,6 +24,7 @@ import Severity from 'vs/base/common/severity';
2424import { coalesce } from 'vs/base/common/arrays' ;
2525import { trim } from 'vs/base/common/strings' ;
2626import { IModeService } from 'vs/editor/common/services/modeService' ;
27+ import { ILabelService } from 'vs/platform/label/common/label' ;
2728
2829export abstract class AbstractFileDialogService implements IFileDialogService {
2930
@@ -39,7 +40,9 @@ export abstract class AbstractFileDialogService implements IFileDialogService {
3940 @IFileService protected readonly fileService : IFileService ,
4041 @IOpenerService protected readonly openerService : IOpenerService ,
4142 @IDialogService private readonly dialogService : IDialogService ,
42- @IModeService private readonly modeService : IModeService
43+ @IModeService private readonly modeService : IModeService ,
44+ @IWorkspacesService private readonly workspacesService : IWorkspacesService ,
45+ @ILabelService private readonly labelService : ILabelService
4346 ) { }
4447
4548 defaultFilePath ( schemeFilter = this . getSchemeFilterForWindow ( ) ) : URI | undefined {
@@ -132,6 +135,11 @@ export abstract class AbstractFileDialogService implements IFileDialogService {
132135 const stat = await this . fileService . resolve ( uri ) ;
133136
134137 const toOpen : IWindowOpenable = stat . isDirectory ? { folderUri : uri } : { fileUri : uri } ;
138+ if ( ! isWorkspaceToOpen ( toOpen ) && isFileToOpen ( toOpen ) ) {
139+ // add the picked file into the list of recently opened
140+ this . workspacesService . addRecentlyOpened ( [ { fileUri : toOpen . fileUri , label : this . labelService . getUriLabel ( toOpen . fileUri ) } ] ) ;
141+ }
142+
135143 if ( stat . isDirectory || options . forceNewWindow || preferNewWindow ) {
136144 return this . hostService . openWindow ( [ toOpen ] , { forceNewWindow : options . forceNewWindow } ) ;
137145 } else {
@@ -146,6 +154,9 @@ export abstract class AbstractFileDialogService implements IFileDialogService {
146154
147155 const uri = await this . pickResource ( { canSelectFiles : true , canSelectFolders : false , canSelectMany : false , defaultUri : options . defaultUri , title, availableFileSystems } ) ;
148156 if ( uri ) {
157+ // add the picked file into the list of recently opened
158+ this . workspacesService . addRecentlyOpened ( [ { fileUri : uri , label : this . labelService . getUriLabel ( uri ) } ] ) ;
159+
149160 if ( options . forceNewWindow || preferNewWindow ) {
150161 return this . hostService . openWindow ( [ { fileUri : uri } ] , { forceNewWindow : options . forceNewWindow } ) ;
151162 } else {
0 commit comments