File tree Expand file tree Collapse file tree 4 files changed +10
-17
lines changed
Expand file tree Collapse file tree 4 files changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ export interface NewWindowOptions {
2626export const WindowService = Symbol ( 'WindowService' ) ;
2727
2828/**
29- * The window hash value that is used to spawn a new default window.
29+ * The window hash value that is used to spawn a new default window.
3030 */
31- export const DEFAULT_WINDOW_HASH : string = '# !empty' ;
31+ export const DEFAULT_WINDOW_HASH : string = '!empty' ;
3232
3333export interface WindowService {
3434
Original file line number Diff line number Diff line change @@ -290,7 +290,9 @@ export class ElectronMainApplication {
290290 }
291291
292292 protected async handleMainCommand ( params : ElectronMainExecutionParams , options : ElectronMainCommandOptions ) : Promise < void > {
293- if ( options . file === undefined ) {
293+ if ( params . secondInstance === false ) {
294+ await this . openWindowWithWorkspace ( '' ) ; // restore previous workspace.
295+ } else if ( options . file === undefined ) {
294296 await this . openDefaultWindow ( ) ;
295297 } else {
296298 let workspacePath : string | undefined ;
Original file line number Diff line number Diff line change @@ -130,7 +130,8 @@ export class WorkspaceService implements FrontendApplicationContribution {
130130 protected async doGetDefaultWorkspaceUri ( ) : Promise < string | undefined > {
131131
132132 // If an empty window is explicitly requested do not restore a previous workspace.
133- if ( window . location . hash === DEFAULT_WINDOW_HASH ) {
133+ // Note: `window.location.hash` includes leading "#" if non-empty.
134+ if ( window . location . hash === `#${ DEFAULT_WINDOW_HASH } ` ) {
134135 window . location . hash = '' ;
135136 return undefined ;
136137 }
@@ -213,6 +214,7 @@ export class WorkspaceService implements FrontendApplicationContribution {
213214 this . setURLFragment ( '' ) ;
214215 }
215216 this . updateTitle ( ) ;
217+ await this . server . setMostRecentlyUsedWorkspace ( this . _workspace ? this . _workspace . resource . toString ( ) : '' ) ;
216218 await this . updateWorkspace ( ) ;
217219 }
218220
Original file line number Diff line number Diff line change @@ -92,20 +92,9 @@ export class DefaultWorkspaceServer implements WorkspaceServer {
9292
9393 async setMostRecentlyUsedWorkspace ( uri : string ) : Promise < void > {
9494 this . root = new Deferred ( ) ;
95- const listUri : string [ ] = [ ] ;
96- const oldListUri = await this . getRecentWorkspaces ( ) ;
97- listUri . push ( uri ) ;
98- if ( oldListUri ) {
99- oldListUri . forEach ( element => {
100- if ( element !== uri && element . length > 0 ) {
101- listUri . push ( element ) ;
102- }
103- } ) ;
104- }
10595 this . root . resolve ( uri ) ;
106- this . writeToUserHome ( {
107- recentRoots : listUri
108- } ) ;
96+ const recentRoots = Array . from ( new Set ( [ uri , ...await this . getRecentWorkspaces ( ) ] ) ) ;
97+ this . writeToUserHome ( { recentRoots } ) ;
10998 }
11099
111100 async getRecentWorkspaces ( ) : Promise < string [ ] > {
You can’t perform that action at this time.
0 commit comments