Skip to content

Commit 1b745f9

Browse files
author
Alberto Iannaccone
committed
reveal node with URI
1 parent ebc63e8 commit 1b745f9

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ export class SketchbookWidgetContribution
102102
override registerCommands(registry: CommandRegistry): void {
103103
super.registerCommands(registry);
104104
registry.registerCommand(SketchbookCommands.REVEAL_SKETCH_NODE, {
105-
execute: (treeWidgetId: string, nodeId: string) =>
106-
this.revealSketchNode(treeWidgetId, nodeId),
105+
execute: (treeWidgetId: string, nodeUri: string) =>
106+
this.revealSketchNode(treeWidgetId, nodeUri),
107107
});
108108
registry.registerCommand(SketchbookCommands.OPEN_NEW_WINDOW, {
109109
execute: (arg) => this.openNewWindow(arg.node),
@@ -217,13 +217,13 @@ export class SketchbookWidgetContribution
217217
console.warn(`Could not retrieve active sketchbook tree ID.`);
218218
return;
219219
}
220-
const nodeId = node.id;
220+
const nodeUri = node.uri.toString();
221221
const options: WorkspaceInput = {};
222222
Object.assign(options, {
223223
tasks: [
224224
{
225225
command: SketchbookCommands.REVEAL_SKETCH_NODE.id,
226-
args: [treeWidgetId, nodeId],
226+
args: [treeWidgetId, nodeUri],
227227
},
228228
],
229229
});
@@ -257,13 +257,13 @@ export class SketchbookWidgetContribution
257257

258258
private async revealSketchNode(
259259
treeWidgetId: string,
260-
nodeId: string
260+
nodeUIri: string
261261
): Promise<void> {
262262
return this.widget
263263
.then((widget) => this.shell.activateWidget(widget.id))
264264
.then((widget) => {
265265
if (widget instanceof SketchbookWidget) {
266-
return widget.revealSketchNode(treeWidgetId, nodeId);
266+
return widget.revealSketchNode(treeWidgetId, nodeUIri);
267267
}
268268
});
269269
}

arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-widget.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { Disposable } from '@theia/core/lib/common/disposable';
1111
import { BaseWidget } from '@theia/core/lib/browser/widgets/widget';
1212
import { SketchbookTreeWidget } from './sketchbook-tree-widget';
1313
import { nls } from '@theia/core/lib/common';
14-
import { SelectableTreeNode, TreeWidget } from '@theia/core/lib/browser';
14+
import { SelectableTreeNode } from '@theia/core/lib/browser';
1515
import { CloudSketchbookCompositeWidget } from '../cloud-sketchbook/cloud-sketchbook-composite-widget';
16+
import { URI } from '../../contributions/contribution';
1617

1718
@injectable()
1819
export class SketchbookWidget extends BaseWidget {
@@ -65,7 +66,7 @@ export class SketchbookWidget extends BaseWidget {
6566
return selectedTreeWidgets.shift();
6667
}
6768

68-
async revealSketchNode(treeWidgetId: string, nodeId: string): Promise<void> {
69+
async revealSketchNode(treeWidgetId: string, nodeUri: string): Promise<void> {
6970
const widget = toArray(this.sketchbookTreesContainer.widgets())
7071
.filter(({ id }) => id === treeWidgetId)
7172
.shift();
@@ -76,8 +77,8 @@ export class SketchbookWidget extends BaseWidget {
7677
// TODO: remove this when the remote/local sketchbooks and their widgets are cleaned up.
7778
const findTreeWidget = (
7879
widget: Widget | undefined
79-
): TreeWidget | undefined => {
80-
if (widget instanceof TreeWidget) {
80+
): SketchbookTreeWidget | undefined => {
81+
if (widget instanceof SketchbookTreeWidget) {
8182
return widget;
8283
}
8384
if (widget instanceof CloudSketchbookCompositeWidget) {
@@ -95,15 +96,17 @@ export class SketchbookWidget extends BaseWidget {
9596
return;
9697
}
9798
this.sketchbookTreesContainer.activateWidget(widget);
98-
const treeNode = treeWidget.model.getNode(nodeId);
99+
100+
const treeNode = await treeWidget.model.revealFile(new URI(nodeUri));
99101
if (!treeNode) {
100-
console.warn(`Could not find tree node with ID: ${nodeId}`);
102+
console.warn(`Could not find tree node with URI: ${nodeUri}`);
101103
return;
102104
}
103105
if (!SelectableTreeNode.is(treeNode)) {
104106
console.warn(`Tree node ${treeNode.id} is not selectable.`);
105107
return;
106108
}
109+
107110
treeWidget.model.selectNode(treeNode);
108111
}
109112

0 commit comments

Comments
 (0)