Skip to content

Commit

Permalink
Switch single instance on per default.
Browse files Browse the repository at this point in the history
Also implements VS Code-like behavior when opening second instances

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder committed Jun 20, 2024
1 parent 8d2d0c6 commit b492405
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dev-packages/application-package/src/application-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export namespace FrontendApplicationConfig {
export type BackendApplicationConfig = RequiredRecursive<BackendApplicationConfig.Partial>;
export namespace BackendApplicationConfig {
export const DEFAULT: BackendApplicationConfig = {
singleInstance: false,
singleInstance: true,
frontendConnectionTimeout: 0
};
export interface Partial extends ApplicationConfig {
Expand Down
21 changes: 13 additions & 8 deletions packages/core/src/electron-main/electron-main-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,19 @@ export class ElectronMainApplication {
}

protected async onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise<void> {
const electronWindows = BrowserWindow.getAllWindows();
if (electronWindows.length > 0) {
const electronWindow = electronWindows[0];
if (electronWindow.isMinimized()) {
electronWindow.restore();
}
electronWindow.focus();
}
createYargs(this.processArgv.getProcessArgvWithoutBin(argv), process.cwd())
.help(false)
.command('$0 [file]', false,
cmd => cmd
.positional('file', { type: 'string' }),
async args => {
this.handleMainCommand({
file: args.file,
cwd: process.cwd(),
secondInstance: true
});
},
).parse();
}

protected onWindowAllClosed(event: ElectronEvent): void {
Expand Down

0 comments on commit b492405

Please sign in to comment.