Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ process.env.LC_NUMERIC = 'C';
const config = ${this.prettyStringify(this.pck.props.frontend.config)};
const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};

if (isSingleInstance && !app.requestSingleInstanceLock()) {
if (isSingleInstance && !app.requestSingleInstanceLock(process.argv)) {
// There is another instance running, exit now. The other instance will request focus.
app.quit();
return;
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/electron-main/electron-main-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,19 +746,22 @@ export class ElectronMainApplication {
this.stopContributions();
}

protected async onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise<void> {
if (argv.includes('--open-url')) {
this.openUrl(argv[argv.length - 1]);
protected async onSecondInstance(event: ElectronEvent, _: string[], cwd: string, originalArgv: string[]): Promise<void> {
// the second instance passes it's original argument array as the fourth argument to this method
// The `argv` second parameter is not usable for us since it is mangled by electron before being passed here

if (originalArgv.includes('--open-url')) {
this.openUrl(originalArgv[originalArgv.length - 1]);
} else {
createYargs(this.processArgv.getProcessArgvWithoutBin(argv), process.cwd())
createYargs(this.processArgv.getProcessArgvWithoutBin(originalArgv), cwd)
.help(false)
.command('$0 [file]', false,
cmd => cmd
.positional('file', { type: 'string' }),
async args => {
await this.handleMainCommand({
file: args.file,
cwd: process.cwd(),
cwd: cwd,
secondInstance: true
});
},
Expand Down
Loading