Skip to content

Commit 94f30c3

Browse files
committed
Add --new-window-if-not-first CLI arg
This allows shift+click/middle+click/num+super Windows and Unity shortcuts to work as expected while not changing regular launch behavior. Part of #48
1 parent 019ce0e commit 94f30c3

5 files changed

Lines changed: 6 additions & 4 deletions

File tree

resources/linux/code.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Name=@@NAME_LONG@@
33
Comment=Code Editing. Redefined.
44
GenericName=Text Editor
5-
Exec=/usr/share/@@NAME@@/@@NAME@@ %U
5+
Exec=/usr/share/@@NAME@@/@@NAME@@ --new-window-if-not-first %U
66
Icon=@@NAME@@
77
Type=Application
88
StartupNotify=true

src/vs/code/electron-main/launch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class LaunchService implements ILaunchService {
9393
let usedWindows: VSCodeWindow[];
9494
if (!!args.extensionDevelopmentPath) {
9595
this.windowsService.openExtensionDevelopmentHostWindow({ context, cli: args, userEnv });
96-
} else if (args._.length === 0 && args['new-window']) {
96+
} else if (args._.length === 0 && args['new-window'] || args['new-window-if-not-first']) {
9797
usedWindows = this.windowsService.open({ context, cli: args, userEnv, forceNewWindow: true, forceEmpty: true });
9898
} else if (args._.length === 0) {
9999
usedWindows = [this.windowsService.focusLastActive(args, context)];
@@ -102,7 +102,7 @@ export class LaunchService implements ILaunchService {
102102
context,
103103
cli: args,
104104
userEnv,
105-
forceNewWindow: args.wait || args['new-window'],
105+
forceNewWindow: args.wait || args['new-window'] || args['new-window-if-not-first'],
106106
preferNewWindow: !args['reuse-window'],
107107
forceReuseWindow: args['reuse-window'],
108108
diffMode: args.diff

src/vs/code/electron-main/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
257257
} else if (global.macOpenFiles && global.macOpenFiles.length && (!environmentService.args._ || !environmentService.args._.length)) {
258258
windowsMainService.open({ context: OpenContext.DOCK, cli: environmentService.args, pathsToOpen: global.macOpenFiles, initialStartup: true }); // mac: open-file event received on startup
259259
} else {
260-
windowsMainService.open({ context, cli: environmentService.args, forceNewWindow: environmentService.args['new-window'], diffMode: environmentService.args.diff, initialStartup: true }); // default: read paths from cli
260+
windowsMainService.open({ context, cli: environmentService.args, forceNewWindow: environmentService.args['new-window'] || environmentService.args['new-window-if-not-first'], diffMode: environmentService.args.diff, initialStartup: true }); // default: read paths from cli
261261
}
262262

263263
// Install Menu

src/vs/platform/environment/common/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ParsedArgs {
1414
diff?: boolean;
1515
goto?: boolean;
1616
'new-window'?: boolean;
17+
'new-window-if-not-first'?: boolean;
1718
'reuse-window'?: boolean;
1819
locale?: string;
1920
'user-data-dir'?: string;

src/vs/platform/environment/node/argv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const options: minimist.Opts = {
3030
'diff',
3131
'goto',
3232
'new-window',
33+
'new-window-if-not-first',
3334
'reuse-window',
3435
'performance',
3536
'verbose',

0 commit comments

Comments
 (0)