Skip to content

Commit fe0ca63

Browse files
committed
Make opening windows from args a bit more lenient
1 parent 38585e8 commit fe0ca63

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

arduino-ide-extension/src/electron-main/theia/electron-main-application.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
8383
return;
8484
}
8585

86-
if (!os.isOSX && await this.launchWindowsOpen(params)) {
86+
if (!os.isOSX && await this.launchFromArgs(params)) {
8787
// Application has received a file in its arguments and will skip the default application launch
8888
return;
8989
}
@@ -105,27 +105,20 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
105105
}
106106
}
107107

108-
protected async launchWindowsOpen(params: ElectronMainExecutionParams): Promise<boolean> {
108+
protected async launchFromArgs(params: ElectronMainExecutionParams): Promise<boolean> {
109109
// Copy to prevent manipulation of original array
110110
const argCopy = [...params.argv];
111-
if (app.isPackaged) {
112-
// workaround for missing executable argument when app is packaged
113-
argCopy.unshift('packaged');
114-
}
115-
const possibleUris = argCopy.slice(2) || null;
116-
if (possibleUris) {
117-
let uri: string | undefined;
118-
for (const possibleUri of possibleUris) {
119-
if (possibleUri.endsWith('.ino') && await this.isValidSketchPath(possibleUri)) {
120-
uri = possibleUri;
121-
break;
122-
}
123-
}
124-
if (uri) {
125-
await this.openSketch(dirname(uri));
126-
return true;
111+
let uri: string | undefined;
112+
for (const possibleUri of argCopy) {
113+
if (possibleUri.endsWith('.ino') && await this.isValidSketchPath(possibleUri)) {
114+
uri = possibleUri;
115+
break;
127116
}
128117
}
118+
if (uri) {
119+
await this.openSketch(dirname(uri));
120+
return true;
121+
}
129122
return false;
130123
}
131124

@@ -170,7 +163,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
170163
}
171164

172165
protected async onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise<void> {
173-
if (!os.isOSX && await this.launchWindowsOpen({ cwd, argv, secondInstance: true })) {
166+
if (!os.isOSX && await this.launchFromArgs({ cwd, argv, secondInstance: true })) {
174167
// Application has received a file in its arguments
175168
return;
176169
}

0 commit comments

Comments
 (0)