-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Description
Currently a user can set window.nativeTabs but to be able to create such tabs there's only these options:
-
Set "Prefer tabs" to "Always" in the global macOS settings. This works because if
window.nativeTabsis set totrue, VS Code setstabbingIdentifier, which causes macOS to open in a native tab when the global option is set. -
Call the
workbench.action.newWindowTabcommand, also accessible by menu with Window -> New Tab (see Add a command to open a new window as tab (Sierra tabs) #25919). This causes VS Code to calladdTabbedWindowto force opening in a tab regardless of the global macOS setting.
Both of these have drawbacks:
-
Setting the global option is not desirable for all users as this has global effect, for instance this causes Finder windows to always open in tabs.
-
Using the
newWindowTabcommand does not work in the general case, for instance when using other commands or actions that open a new window.
Furthermore the current behavior is non-obvious as users expect enabling native tabs would immediately work for all actions that create a new window. It's not obvious users need to change the global setting, see #25919 (comment), and I saw other comments from confused users in other posts.
I think ideally setting window.nativeTabs to true should cause all new windows to open in tabs by default. Creating a new window would still be possible by first creating a new tab then dragging it out, same process as when the global macOS setting for tabs is set to "always". However I guess it's too late to change that behaviour so the next best thing would be to add a new setting.
The following patch works well for me. It calls addTabbedWindow() for all new windows if the window.openNewWindowsInNativeTabs is set:
diff --git a/src/vs/platform/windows/electron-main/windowsMainService.ts b/src/vs/platform/windows/electron-main/windowsMainService.ts
index 594b8364353..04547d828f1 100644
--- a/src/vs/platform/windows/electron-main/windowsMainService.ts
+++ b/src/vs/platform/windows/electron-main/windowsMainService.ts
@@ -1529,9 +1529,10 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
});
mark('code/didCreateCodeWindow');
// Add as window tab if configured (macOS only)
- if (options.forceNewTabbedWindow) {
+ const forceNewTabbedWindow = this.configurationService.getValue<boolean>('window.openNewWindowsInNativeTabs')
+ if (forceNewTabbedWindow || options.forceNewTabbedWindow) {
const activeWindow = this.getLastActiveWindow();
activeWindow?.addTabbedWindow(createdWindow);
}I'd be happy to send a PR with a properly documented setting if you're interested.