Skip to content

Commit 7d17dd5

Browse files
author
Alberto Iannaccone
committed
enable sending commands via query params
1 parent f5a1ae4 commit 7d17dd5

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ import { FrontendApplication } from '@theia/core/lib/browser/frontend-applicatio
99
import { FocusTracker, Widget } from '@theia/core/lib/browser';
1010
import { DEFAULT_WINDOW_HASH } from '@theia/core/lib/common/window';
1111
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
12-
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
12+
import {
13+
WorkspaceInput,
14+
WorkspaceService as TheiaWorkspaceService,
15+
} from '@theia/workspace/lib/browser/workspace-service';
1316
import { ConfigService } from '../../../common/protocol/config-service';
1417
import {
1518
SketchesService,
1619
Sketch,
1720
} from '../../../common/protocol/sketches-service';
1821
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
1922
import { BoardsConfig } from '../../boards/boards-config';
23+
import { Command } from '@theia/core';
24+
25+
interface WorkspaceOptions extends WorkspaceInput {
26+
commands: Command[];
27+
}
2028

2129
@injectable()
2230
export class WorkspaceService extends TheiaWorkspaceService {
@@ -42,6 +50,7 @@ export class WorkspaceService extends TheiaWorkspaceService {
4250
protected readonly boardsServiceProvider: BoardsServiceProvider;
4351

4452
private version?: string;
53+
private optionsToAppendToURI?: WorkspaceOptions;
4554

4655
async onStart(application: FrontendApplication): Promise<void> {
4756
const info = await this.applicationServer.getApplicationInfo();
@@ -82,13 +91,25 @@ export class WorkspaceService extends TheiaWorkspaceService {
8291
}
8392
}
8493

94+
override open(uri: URI, options?: WorkspaceOptions): void {
95+
this.optionsToAppendToURI = options;
96+
super.doOpen(uri);
97+
}
98+
8599
protected override openNewWindow(workspacePath: string): void {
86100
const { boardsConfig } = this.boardsServiceProvider;
87101
const url = BoardsConfig.Config.setConfig(
88102
boardsConfig,
89103
new URL(window.location.href)
90104
); // Set the current boards config for the new browser window.
91105
url.hash = workspacePath;
106+
if (this.optionsToAppendToURI) {
107+
url.searchParams.set(
108+
'commands',
109+
encodeURIComponent(JSON.stringify(this.optionsToAppendToURI?.commands))
110+
);
111+
this.optionsToAppendToURI = undefined;
112+
}
92113
this.windowService.openNewWindow(url.toString());
93114
}
94115

0 commit comments

Comments
 (0)