8000 get ws root withot check. · arduino/arduino-ide@986d597 · GitHub
[go: up one dir, main page]

Skip to content

Commit 986d597

Browse files
author
Akos Kitta
committed
get ws root withot check.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 5da4b1a commit 986d597

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

arduino-ide-extension/src/browser/theia/workspace/workspace-service.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { MessageService } from '@theia/core/lib/common/message-service';
77
import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
88
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
99
import { FocusTracker, Widget } from '@theia/core/lib/browser';
10+
import { DEFAULT_WINDOW_HASH } from '@theia/core/lib/common/window';
1011
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
1112
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
1213
import { ConfigService } from '../../../common/protocol/config-service';
@@ -61,6 +62,30 @@ export class WorkspaceService extends TheiaWorkspaceService {
6162
this.onCurrentWidgetChange({ newValue, oldValue: null });
6263
}
6364

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+
6489
protected getDefaultWorkspaceUri(): Promise<string | undefined> {
6590
if (this.workspaceUri) {
6691
// Avoid creating a new sketch twice

0 commit comments

Comments
 (0)
0