Skip to content

Commit ec71004

Browse files
committed
ATL-1451: reveal sketch directory in file explorer
1 parent 84d8232 commit ec71004

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { shell } from 'electron';
1+
import { remote } from 'electron';
22
import { inject, injectable } from 'inversify';
33
import { CommandRegistry } from '@theia/core/lib/common/command';
44
import { MenuModelRegistry } from '@theia/core/lib/common/menu';
@@ -25,6 +25,7 @@ import {
2525
} from '@theia/core/lib/common/disposable';
2626
import { SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl';
2727
import { FileService } from '@theia/filesystem/lib/browser/file-service';
28+
import { URI } from '../../contributions/contribution';
2829

2930
export const SKETCHBOOK__CONTEXT = ['arduino-sketchbook--context'];
3031

@@ -111,8 +112,16 @@ export class SketchbookWidgetContribution
111112
});
112113

113114
registry.registerCommand(SketchbookCommands.REVEAL_IN_FINDER, {
114-
execute: (arg) => {
115-
shell.openPath(arg.node.id);
115+
execute: async (arg) => {
116+
if (arg.node.uri) {
117+
const exists = await this.fileService.exists(new URI(arg.node.uri));
118+
if (exists) {
119+
const fsPath = await this.fileService.fsPath(new URI(arg.node.uri));
120+
if (fsPath) {
121+
remote.shell.openPath(fsPath);
122+
}
123+
}
124+
}
116125
},
117126
isEnabled: (arg) =>
118127
!!arg && 'node' in arg && SketchbookTree.SketchDirNode.is(arg.node),

0 commit comments

Comments
 (0)