Skip to content

Commit 682f2cc

Browse files
author
Akos Kitta
committed
fix: openPath and showItemInFolder regressions
Signed-off-by: Akos Kitta <[email protected]>
1 parent 6ab705d commit 682f2cc

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

Diff for: arduino-ide-extension/src/browser/contributions/open-sketch-external.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { injectable } from '@theia/core/shared/inversify';
22
import URI from '@theia/core/lib/common/uri';
3-
import { CommandService } from '@theia/core/lib/common/command';
43
import { ArduinoMenus } from '../menu/arduino-menus';
54
import {
65
SketchContribution,
@@ -15,7 +14,7 @@ import { nls } from '@theia/core/lib/common/nls';
1514
export class OpenSketchExternal extends SketchContribution {
1615
override registerCommands(registry: CommandRegistry): void {
1716
registry.registerCommand(OpenSketchExternal.Commands.OPEN_EXTERNAL, {
18-
execute: () => this.openExternal(registry),
17+
execute: () => this.openExternal(),
1918
});
2019
}
2120

@@ -34,14 +33,14 @@ export class OpenSketchExternal extends SketchContribution {
3433
});
3534
}
3635

37-
protected async openExternal(commandService: CommandService): Promise<void> {
36+
protected async openExternal(): Promise<void> {
3837
const uri = await this.sketchServiceClient.currentSketchFile();
3938
if (uri) {
4039
const exists = await this.fileService.exists(new URI(uri));
4140
if (exists) {
4241
const fsPath = await this.fileService.fsPath(new URI(uri));
4342
if (fsPath) {
44-
commandService.executeCommand('revealFileInOS', fsPath);
43+
window.electronTheiaCore.showItemInFolder(fsPath);
4544
}
4645
}
4746
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class SketchbookWidgetContribution
119119
if (exists) {
120120
const fsPath = await this.fileService.fsPath(new URI(arg.node.uri));
121121
if (fsPath) {
122-
registry.executeCommand('revealFileInOS', fsPath);
122+
window.electronArduino.openPath(fsPath);
123123
}
124124
}
125125
}

Diff for: arduino-ide-extension/src/electron-browser/preload.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { Sketch } from '../common/protocol/sketches-service';
88
import {
99
CHANNEL_APP_VERSION,
1010
CHANNEL_IS_FIRST_WINDOW,
11+
CHANNEL_OPEN_PATH,
1112
CHANNEL_PLOTTER_WINDOW_DID_CLOSE,
1213
CHANNEL_QUIT_APP,
1314
CHANNEL_SCHEDULE_DELETION,
@@ -22,7 +23,7 @@ import {
2223
OpenDialogOptions,
2324
SaveDialogOptions,
2425
} from '../electron-common/electron-arduino';
25-
import { hasStartupTasks, StartupTasks } from '../electron-common/startup-task';
26+
import { StartupTasks, hasStartupTasks } from '../electron-common/startup-task';
2627

2728
const api: ElectronArduino = {
2829
showMessageBox: (options: MessageBoxOptions) =>
@@ -66,6 +67,7 @@ const api: ElectronArduino = {
6667
ipcRenderer.removeListener(CHANNEL_PLOTTER_WINDOW_DID_CLOSE, listener)
6768
);
6869
},
70+
openPath: (fsPath: string) => ipcRenderer.send(CHANNEL_OPEN_PATH, fsPath),
6971
};
7072

7173
export function preload(): void {

Diff for: arduino-ide-extension/src/electron-common/electron-arduino.ts

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface ElectronArduino {
5050
setRepresentedFilename(fsPath: string): void;
5151
showPlotterWindow(params: { url: string; forceReload?: boolean }): void;
5252
registerPlotterWindowCloseHandler(handler: () => void): Disposable;
53+
openPath(fsPath: string): void;
5354
}
5455

5556
declare global {
@@ -69,6 +70,7 @@ export const CHANNEL_SCHEDULE_DELETION = 'Arduino:ScheduleDeletion';
6970
export const CHANNEL_SET_REPRESENTED_FILENAME =
7071
'Arduino:SetRepresentedFilename';
7172
export const CHANNEL_SHOW_PLOTTER_WINDOW = 'Arduino:ShowPlotterWindow';
73+
export const CHANNEL_OPEN_PATH = 'Arduino:OpenPath';
7274
// main to renderer
7375
export const CHANNEL_SEND_STARTUP_TASKS = 'Arduino:SendStartupTasks';
7476
export const CHANNEL_PLOTTER_WINDOW_DID_CLOSE = 'Arduino:PlotterWindowDidClose';

Diff for: arduino-ide-extension/src/electron-main/electron-arduino.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ import {
33
dialog,
44
ipcMain,
55
IpcMainEvent,
6+
shell,
67
} from '@theia/core/electron-shared/electron';
78
import { Disposable } from '@theia/core/lib/common/disposable';
89
import { CHANNEL_REQUEST_RELOAD } from '@theia/core/lib/electron-common/electron-api';
910
import {
10-
ElectronMainApplication as TheiaElectronMainApplication,
1111
ElectronMainApplicationContribution,
12+
ElectronMainApplication as TheiaElectronMainApplication,
1213
} from '@theia/core/lib/electron-main/electron-main-application';
1314
import { createDisposableListener } from '@theia/core/lib/electron-main/event-utils';
1415
import { injectable } from '@theia/core/shared/inversify';
1516
import { WebContents } from '@theia/electron/shared/electron';
1617
import {
1718
CHANNEL_APP_VERSION,
1819
CHANNEL_IS_FIRST_WINDOW,
20+
CHANNEL_OPEN_PATH,
1921
CHANNEL_QUIT_APP,
2022
CHANNEL_SEND_STARTUP_TASKS,
2123
CHANNEL_SET_REPRESENTED_FILENAME,
@@ -94,6 +96,9 @@ export class ElectronArduino implements ElectronMainApplicationContribution {
9496
window.setRepresentedFilename(fsPath);
9597
}
9698
});
99+
ipcMain.on(CHANNEL_OPEN_PATH, (_, fsPath: string) => {
100+
shell.openPath(fsPath);
101+
});
97102
}
98103
}
99104

0 commit comments

Comments
 (0)