Skip to content

Commit 309b137

Browse files
author
Alberto Iannaccone
committed
clean up OPEN_NEW_WINDOW command
1 parent 6b4e00d commit 309b137

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,7 @@ export class SketchbookWidgetContribution
106106
this.revealSketchNode(treeWidgetId, nodeId),
107107
});
108108
registry.registerCommand(SketchbookCommands.OPEN_NEW_WINDOW, {
109-
execute: (arg) => {
110-
const widget = this.tryGetWidget();
111-
if (widget) {
112-
const treeWidgetId = widget.activeTreeWidgetId();
113-
if (!treeWidgetId) {
114-
console.warn(`Could not retrieve active sketchbook tree ID.`);
115-
return;
116-
}
117-
const nodeId = arg.node.id;
118-
const options: WorkspaceInput = {};
119-
Object.assign(options, {
120-
tasks: [
121-
{
122-
command: SketchbookCommands.REVEAL_SKETCH_NODE.id,
123-
args: [treeWidgetId, nodeId],
124-
},
125-
],
126-
});
127-
return this.workspaceService.open(arg.node.uri, options);
128-
}
129-
},
109+
execute: (arg) => this.openNewWindow(arg.node),
130110
isEnabled: (arg) =>
131111
!!arg && 'node' in arg && SketchbookTree.SketchDirNode.is(arg.node),
132112
isVisible: (arg) =>
@@ -229,6 +209,28 @@ export class SketchbookWidgetContribution
229209
});
230210
}
231211

212+
private openNewWindow(node: SketchbookTree.SketchDirNode): void {
213+
const widget = this.tryGetWidget();
214+
if (widget) {
215+
const treeWidgetId = widget.activeTreeWidgetId();
216+
if (!treeWidgetId) {
217+
console.warn(`Could not retrieve active sketchbook tree ID.`);
218+
return;
219+
}
220+
const nodeId = node.id;
221+
const options: WorkspaceInput = {};
222+
Object.assign(options, {
223+
tasks: [
224+
{
225+
command: SketchbookCommands.REVEAL_SKETCH_NODE.id,
226+
args: [treeWidgetId, nodeId],
227+
},
228+
],
229+
});
230+
return this.workspaceService.open(node.uri, options);
231+
}
232+
}
233+
232234
/**
233235
* Reveals and selects node in the file navigator to which given widget is related.
234236
* Does nothing if given widget undefined or doesn't have related resource.

0 commit comments

Comments
 (0)