@@ -7,6 +7,7 @@ import { MessageService } from '@theia/core/lib/common/message-service';
7
7
import { ApplicationServer } from '@theia/core/lib/common/application-protocol' ;
8
8
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application' ;
9
9
import { FocusTracker , Widget } from '@theia/core/lib/browser' ;
10
+ import { DEFAULT_WINDOW_HASH } from '@theia/core/lib/common/window' ;
10
11
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
11
12
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service' ;
12
13
import { ConfigService } from '../../../common/protocol/config-service' ;
@@ -61,6 +62,30 @@ export class WorkspaceService extends TheiaWorkspaceService {
61
62
this . onCurrentWidgetChange ( { newValue, oldValue : null } ) ;
62
63
}
63
64
65
+ // Was copied from the Theia implementation.
66
+ // Unlike the default behavior, IDE2 does not check the existence of the workspace before open.
67
+ protected async doGetDefaultWorkspaceUri ( ) : Promise < string | undefined > {
68
+ // If an empty window is explicitly requested do not restore a previous workspace.
69
+ // Note: `window.location.hash` includes leading "#" if non-empty.
70
+ if ( window . location . hash === `#${ DEFAULT_WINDOW_HASH } ` ) {
71
+ window . location . hash = '' ;
72
+ return undefined ;
73
+ }
74
+
75
+ // Prefer the workspace path specified as the URL fragment, if present.
76
+ if ( window . location . hash . length > 1 ) {
77
+ // Remove the leading # and decode the URI.
78
+ const wpPath = decodeURI ( window . location . hash . substring ( 1 ) ) ;
79
+ const workspaceUri = new URI ( ) . withPath ( wpPath ) . withScheme ( 'file' ) ;
80
+ // Customization! Here, we do no check if the workspace exists.
81
+ return workspaceUri . toString ( ) ;
82
+ } else {
83
+ // Else, ask the server for its suggested workspace (usually the one
84
+ // specified on the CLI, or the most recent).
85
+ return this . server . getMostRecentlyUsedWorkspace ( ) ;
86
+ }
87
+ }
88
+
64
89
protected getDefaultWorkspaceUri ( ) : Promise < string | undefined > {
65
90
if ( this . workspaceUri ) {
66
91
// Avoid creating a new sketch twice
0 commit comments