Skip to content

Commit a6d762a

Browse files
author
Alberto Iannaccone
committed
requested changes
1 parent e1ef5e2 commit a6d762a

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-widget.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ import { CommandContribution, CommandRegistry } from '@theia/core';
1010
import { ApplicationShell } from '@theia/core/lib/browser';
1111
import { CloudSketchbookCommands } from './cloud-sketchbook-contributions';
1212
import { EditorManager } from '@theia/editor/lib/browser';
13+
import { SketchbookWidgetContribution } from '../sketchbook/sketchbook-widget-contribution';
1314

1415
@injectable()
1516
export class CloudSketchbookWidget
1617
extends SketchbookWidget
1718
implements CommandContribution
1819
{
1920
@inject(CloudSketchbookCompositeWidget)
20-
protected readonly cloudSketchbookCompositeWidget: CloudSketchbookCompositeWidget;
21+
private readonly cloudSketchbookCompositeWidget: CloudSketchbookCompositeWidget;
2122

2223
@inject(ArduinoPreferences)
23-
protected readonly arduinoPreferences: ArduinoPreferences;
24+
private readonly arduinoPreferences: ArduinoPreferences;
2425

2526
@inject(ApplicationShell)
26-
protected readonly shell: ApplicationShell;
27+
private readonly shell: ApplicationShell;
28+
29+
@inject(SketchbookWidgetContribution)
30+
private readonly sketchbookWidgetContribution: SketchbookWidgetContribution;
2731

2832
@inject(EditorManager)
29-
protected readonly editorManager: EditorManager;
33+
private readonly editorManager: EditorManager;
3034

3135
@postConstruct()
3236
protected override init(): void {
@@ -94,8 +98,9 @@ export class CloudSketchbookWidget
9498
if (widget instanceof CloudSketchbookWidget) {
9599
widget.activateTreeWidget(this.cloudSketchbookCompositeWidget.id);
96100
}
97-
if (this.editorManager.currentEditor)
98-
this.shell.activateWidget(this.editorManager.currentEditor.id);
101+
this.sketchbookWidgetContribution.selectWidgetFileNode(
102+
this.editorManager.currentEditor
103+
);
99104
});
100105
}
101106
}

arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-widget-contribution.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class SketchbookWidgetContribution
123123
override registerCommands(registry: CommandRegistry): void {
124124
super.registerCommands(registry);
125125
registry.registerCommand(SketchbookCommands.SHOW_SKETCHBOOK_WIDGET, {
126-
execute: () => this.showSketchbookWidget(),
126+
execute: () => this.showLocalSketchbookWidget(),
127127
});
128128
registry.registerCommand(SketchbookCommands.OPEN_NEW_WINDOW, {
129129
execute: (arg) => this.openSketchInNewWindow(arg),
@@ -262,14 +262,13 @@ export class SketchbookWidgetContribution
262262
this.selectWidgetFileNode(this.shell.currentWidget);
263263
}
264264

265-
protected async showSketchbookWidget(): Promise<void> {
265+
protected async showLocalSketchbookWidget(): Promise<void> {
266266
this.widget
267267
.then((widget) => this.shell.activateWidget(widget.id))
268268
.then((widget) => {
269269
if (widget instanceof SketchbookWidget) {
270270
widget.activateTreeWidget(widget.getTreeWidget().id);
271-
if (this.editorManager.currentEditor)
272-
this.shell.activateWidget(this.editorManager.currentEditor.id);
271+
this.selectWidgetFileNode(this.editorManager.currentEditor);
273272
}
274273
});
275274
}
@@ -281,10 +280,9 @@ export class SketchbookWidgetContribution
281280

282281
const commands = JSON.parse(decodeURIComponent(encoded));
283282

284-
if (commands && Array.isArray(commands)) {
283+
if (Array.isArray(commands)) {
285284
commands.forEach((c: Command) => {
286-
if (this.commandRegistry.commandIds.includes(c.id))
287-
this.commandRegistry.executeCommand(c.id);
285+
this.commandRegistry.executeCommand(c.id);
288286
});
289287
}
290288
}

0 commit comments

Comments
 (0)