Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 77b7ef9

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

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

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

Lines changed: 6 additions & 6 deletions
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‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ 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';
1514
import { CloudSketchbookCompositeWidget } from '../cloud-sketchbook/cloud-sketchbook-composite-widget';
15+
import { URI } from '../../contributions/contribution';
1616

1717
@injectable()
1818
export class SketchbookWidget extends BaseWidget {
@@ -65,7 +65,7 @@ export class SketchbookWidget extends BaseWidget {
6565
return selectedTreeWidgets.shift();
6666
}
6767

68-
async revealSketchNode(treeWidgetId: string, nodeId: string): Promise<void> {
68+
async revealSketchNode(treeWidgetId: string, nodeUri: string): Promise<void> {
6969
const widget = toArray(this.sketchbookTreesContainer.widgets())
7070
.filter(({ id }) => id === treeWidgetId)
7171
.shift();
@@ -76,8 +76,8 @@ export class SketchbookWidget extends BaseWidget {
7676
// TODO: remove this when the remote/local sketchbooks and their widgets are cleaned up.
7777
const findTreeWidget = (
7878
widget: Widget | undefined
79-
): TreeWidget | undefined => {
80-
if (widget instanceof TreeWidget) {
79+
): SketchbookTreeWidget | undefined => {
80+
if (widget instanceof SketchbookTreeWidget) {
8181
return widget;
8282
}
8383
if (widget instanceof CloudSketchbookCompositeWidget) {
@@ -95,16 +95,12 @@ export class SketchbookWidget extends BaseWidget {
9595
return;
9696
}
9797
this.sketchbookTreesContainer.activateWidget(widget);
98-
const treeNode = treeWidget.model.getNode(nodeId);
98+
99+
const treeNode = await treeWidget.model.revealFile(new URI(nodeUri));
99100
if (!treeNode) {
100-
console.warn(`Could not find tree node with ID: ${nodeId}`);
101-
return;
102-
}
103-
if (!SelectableTreeNode.is(treeNode)) {
104-
console.warn(`Tree node ${treeNode.id} is not selectable.`);
101+
console.warn(`Could not find tree node with URI: ${nodeUri}`);
105102
return;
106103
}
107-
treeWidget.model.selectNode(treeNode);
108104
}
109105

110106
protected override onActivateRequest(message: Message): void {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /