You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clicking shortcut to WT PowerShell profile opens 2 windows #14799
Edition Windows 11 Pro Version 22H2 Installed on 12-8-2022 OS build 22621.1194 Experience Windows Feature Experience Pack 1000.22638.1000.0
Other Software
PowerShell 7.3.2
Steps to reproduce
1 Create a Windows shortcut with the command line C:\Users\willp\AppData\Local\Microsoft\WindowsApps\wt.exe -p "PowerShell"
2 Create a matching WT profile
3 Click the shortcut
How many windows opened?
Expected Behavior
I'd expect only at most one new window.
Actual Behavior
With no WT widows open, I get two to the same profile.
Are you sure you have 1.16.10261 installed? That's the version for Windows 10. You can replace it with 1.16.10262 from here.
Additionally I'm not sure how your 1. and 2. step fit together: The "PowerShell" profile is a standard profile and should always exist unless you deleted it previously. Is "PowerShell" in your first step just an example or is the 2. step optional?
Interesting... I can't reproduce this behavior with 1.16.10262.0 and PowerShell 7.3.2. What happens if you add -NoProfile to the command line of your "PowerShell" profile? If that doesn't fix the issue, could you share your settings.json?
I've run into this as well. Using "firstWindowPreference": "persistedWindowLayout" causes Windows Terminal to open multiple windows, depending on the command line used to launch it.
wt -d . will open 2 windows. One with the previous session and a new one with a shell window for the current directory.
I think the expected behavior here is that a single window is opened with the previous session and a new shell instance is added to that window.
Yea, this is just kinda by-design for now. If you don't have any Terminal windows open, and have "firstWindowPreference": "persistedWindowLayout" set, and run a wt commandline that's not justwt.exe (e.g. wt -d .), then we'll open up the old windows, AND open the new thing you've asked for (in this case, the new-tab -d .). This is roughly consistent with how browsers work, if you did something like edge.exe github.com without any windows currently open.
I suppose theoretically, this could also respect the "windowingBehavior" setting. If that was set to use*Existing, then theoretically I suppose we should append the passed commandline to whatever commandline we're going to restore from. That would make sense.
I'll leave this open, on the backlog. I've been playing in the state restoration code quite a bit recently, and I don't think this would be super easy to fix...
Just as a data point one place where this comes up naturally is vscode. When it launches an external terminal it passes the current directory. I don't think this is configurable by the user, but it's the desired behavior in any case.
Respecting windowingBehavior makes sense to me, personally, and would be desirable.
I had the same issue and I initially (naively confused!) thought this was VSCode's issue.
I've added a GIF at: microsoft/vscode#183401
I think it's annoying in case of VSCode and makes such a brilliant option (open external terminal) useless. My laptop screen is small and I tend to use the external terminal rather than the integrated one, but everytime I re-open the external terminal, I have to close the extra one.
Another similar issue has also been added at: #14932
Based on what I've read here, the current behavior is respecting some conventions, but I guess you might be able to add some third option or a flag? Then that flag might be usable in VSCode default terminal settings (I've not tested this though).
My expected behavior is also, that if I use default Start Menu shortcut (that Windows store created when installing Terminal) to launch the Terminal, it'll restore my old session as/if configured from the settings to do so, but does NOT open anything else UNLESS I specifically tell it to with separate arguments. And there's a lot of different possibilities:
There's a difference choosing between these things:
Open previous session tabs and windows
Open previous session and ATTACH the new window as a tab to the previous session window
Open previous session and open this new shell/terminal as a new window
Open new window and discard old session
It's many things and possibilities and as it stands it doesn't seem to be very exclusive in how to handle it properly.
From browsers I've come to expect (and from notepad++ for that matter) that launching the application itself without arguments doesn't automatically open new tab or window, it either restores my old session 1:1 OR starts from scratch depending what configuration was active. If I want to open extra tab/window to a location, I should explicitly command it to do so.
As a user, I expect it to open to the last window I used in the session that's being restored (let's say session had 3 windows, if I was using specific window before closing the session [based on what window was in focus?], THAT'S the one I expect the new tab to open to), unless I specifically have an option to choose where it opens to based on arguments or profile configuration.
Like in NPP, It opens all the previous tabs AND it'll attach the new file that I gave as an argument to the end of that tab list.
I hope you'll figure it out... it's not an easy problem by any means to tackle. :)
Activity
lhecker commentedon Feb 7, 2023
Are you sure you have 1.16.10261 installed? That's the version for Windows 10. You can replace it with 1.16.10262 from here.
Additionally I'm not sure how your 1. and 2. step fit together: The "PowerShell" profile is a standard profile and should always exist unless you deleted it previously. Is "PowerShell" in your first step just an example or is the 2. step optional?
Interesting... I can't reproduce this behavior with 1.16.10262.0 and PowerShell 7.3.2. What happens if you add
-NoProfileto the command line of your "PowerShell" profile? If that doesn't fix the issue, could you share your settings.json?WillPittenger commentedon Feb 7, 2023
It's proving to be intermittent. Yes, that's the version I see installed. I copied the version number from the About dialog.

DHowett commentedon Feb 7, 2023
Do you, by chance, have this setting set?
WillPittenger commentedon Feb 7, 2023
I have "Open Windows from a previous session". That might be it. I was hoping to see my previous PS session.
carlos-zamora commentedon Feb 8, 2023
Did this turn out to be your issue?
akbyrd commentedon Feb 12, 2023
I've run into this as well. Using
"firstWindowPreference": "persistedWindowLayout"causes Windows Terminal to open multiple windows, depending on the command line used to launch it.wt -d .will open 2 windows. One with the previous session and a new one with a shell window for the current directory.I think the expected behavior here is that a single window is opened with the previous session and a new shell instance is added to that window.
wt -p "PowerShell"has the same issue.Version 1.16.10261.0 on Windows 10
zadjii-msft commentedon Feb 13, 2023
Yea, this is just kinda by-design for now. If you don't have any Terminal windows open, and have
"firstWindowPreference": "persistedWindowLayout"set, and run a wt commandline that's not justwt.exe(e.g.wt -d .), then we'll open up the old windows, AND open the new thing you've asked for (in this case, thenew-tab -d .). This is roughly consistent with how browsers work, if you did something likeedge.exe github.comwithout any windows currently open.I suppose theoretically, this could also respect the
"windowingBehavior"setting. If that was set touse*Existing, then theoretically I suppose we should append the passed commandline to whatever commandline we're going to restore from. That would make sense.I'll leave this open, on the backlog. I've been playing in the state restoration code quite a bit recently, and I don't think this would be super easy to fix...
akbyrd commentedon Feb 13, 2023
Just as a data point one place where this comes up naturally is vscode. When it launches an external terminal it passes the current directory. I don't think this is configurable by the user, but it's the desired behavior in any case.
Respecting
windowingBehaviormakes sense to me, personally, and would be desirable.aderchox commentedon May 27, 2023
I had the same issue and I initially (naively confused!) thought this was VSCode's issue.
I've added a GIF at: microsoft/vscode#183401
I think it's annoying in case of VSCode and makes such a brilliant option (open external terminal) useless. My laptop screen is small and I tend to use the external terminal rather than the integrated one, but everytime I re-open the external terminal, I have to close the extra one.
Another similar issue has also been added at: #14932
Based on what I've read here, the current behavior is respecting some conventions, but I guess you might be able to add some third option or a flag? Then that flag might be usable in VSCode default terminal settings (I've not tested this though).
mtaalas commentedon Jun 4, 2023
My expected behavior is also, that if I use default Start Menu shortcut (that Windows store created when installing Terminal) to launch the Terminal, it'll restore my old session as/if configured from the settings to do so, but does NOT open anything else UNLESS I specifically tell it to with separate arguments. And there's a lot of different possibilities:
There's a difference choosing between these things:
Open previous session tabs and windows
Open previous session and ATTACH the new window as a tab to the previous session window
Open previous session and open this new shell/terminal as a new window
Open new window and discard old session
It's many things and possibilities and as it stands it doesn't seem to be very exclusive in how to handle it properly.
From browsers I've come to expect (and from notepad++ for that matter) that launching the application itself without arguments doesn't automatically open new tab or window, it either restores my old session 1:1 OR starts from scratch depending what configuration was active. If I want to open extra tab/window to a location, I should explicitly command it to do so.
As a user, I expect it to open to the last window I used in the session that's being restored (let's say session had 3 windows, if I was using specific window before closing the session [based on what window was in focus?], THAT'S the one I expect the new tab to open to), unless I specifically have an option to choose where it opens to based on arguments or profile configuration.
Like in NPP, It opens all the previous tabs AND it'll attach the new file that I gave as an argument to the end of that tab list.
I hope you'll figure it out... it's not an easy problem by any means to tackle. :)
zadjii commentedon Jun 4, 2023
Guys what if we restored both the unelevated and the elevated windows when either are launched?