Skip to content

Commit 6b74567

Browse files
committed
Pass the original argv to the "second instance" handler
Fixes eclipse-theia#14747 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <[email protected]>
1 parent 2bd9035 commit 6b74567

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

dev-packages/application-manager/src/generator/backend-generator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const config = ${this.prettyStringify(this.pck.props.frontend.config)};
6464
const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};
6565
6666
(async () => {
67-
if (isSingleInstance && !app.requestSingleInstanceLock()) {
67+
if (isSingleInstance && !app.requestSingleInstanceLock(process.argv)) {
6868
// There is another instance running, exit now. The other instance will request focus.
6969
app.quit();
7070
return;

packages/core/src/electron-main/electron-main-application.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,14 @@ export class ElectronMainApplication {
741741
this.stopContributions();
742742
}
743743

744-
protected async onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise<void> {
745-
if (argv.includes('--open-url')) {
746-
this.openUrl(argv[argv.length - 1]);
744+
protected async onSecondInstance(event: ElectronEvent, _: string[], cwd: string, originalArgv: string[]): Promise<void> {
745+
// the second instance passes it's original argument array as the fourth argument to this method
746+
// The `argv` second parameter is not usable for us since it is mangled by electron before being passed here
747+
748+
if (originalArgv.includes('--open-url')) {
749+
this.openUrl(originalArgv[originalArgv.length - 1]);
747750
} else {
748-
createYargs(this.processArgv.getProcessArgvWithoutBin(argv), process.cwd())
751+
createYargs(this.processArgv.getProcessArgvWithoutBin(originalArgv), process.cwd())
749752
.help(false)
750753
.command('$0 [file]', false,
751754
cmd => cmd

0 commit comments

Comments
 (0)