diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f4cd7eff0935..1a29f079c913c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,9 +9,8 @@
[Breaking Changes:](#breaking_changes_not_yet_released)
- [filesystem] Adjusted the "Save As" mechanism. It now assumes that `Saveable.getSnapshot()` returns a full snapshot of the editor model [#13689](https://github.com/eclipse-theia/theia/pull/13689).
-
--->
-
+- [electron] Switch single instance on per default [#13831](https://github.com/eclipse-theia/theia/pull/13831) - contributed on behalf of STMicroelectronics
+ -->
## 1.50.0 - 06/03/2024
- [application-package] bumped the default supported API from `1.88.1` to `1.89.1` [#13738](https://github.com/eclipse-theia/theia/pull/13738) - contributed on behalf of STMicroelectronics
diff --git a/dev-packages/application-package/src/application-props.ts b/dev-packages/application-package/src/application-props.ts
index 91de09fc319b7..cf9320e7120fd 100644
--- a/dev-packages/application-package/src/application-props.ts
+++ b/dev-packages/application-package/src/application-props.ts
@@ -183,7 +183,7 @@ export namespace FrontendApplicationConfig {
export type BackendApplicationConfig = RequiredRecursive;
export namespace BackendApplicationConfig {
export const DEFAULT: BackendApplicationConfig = {
- singleInstance: false,
+ singleInstance: true,
frontendConnectionTimeout: 0
};
export interface Partial extends ApplicationConfig {
diff --git a/packages/core/src/electron-main/electron-main-application.ts b/packages/core/src/electron-main/electron-main-application.ts
index 8d59807252593..2da08aa9b4031 100644
--- a/packages/core/src/electron-main/electron-main-application.ts
+++ b/packages/core/src/electron-main/electron-main-application.ts
@@ -721,14 +721,19 @@ export class ElectronMainApplication {
}
protected async onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise {
- 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 {