vscode-powershell
vscode-powershell copied to clipboard
Windows spawned from integrated console are hidden behind VS Code window
Update
This is an issue in VSCode that the PowerShell extension has no control over. In fact it's an issue in electron that has yet to be fixed.
To resolve this issue, we are waiting on a solution from VSCode.
Original Issue
There's a general problem where windows spawned from within the PowerShell process are being shown below the VS Code window, more than likely because their window parent is a non-visible powershell.exe process. I need to check if there's a way to set powershell.exe's window parent to VS Code so that windows spawned from within are ultimately parented to VS Code's window instead.
easy to test with:
Invoke-Item .
or
Login-AzureRmAccount
Thanks Matt!
Is it possible to get this added to milestone 44 or 45 https://github.com/PowerShell/vscode-powershell/milestone/44 https://github.com/PowerShell/vscode-powershell/milestone/45
It would be great to get this solved and replace powershell as my main ISE.
Arrived here because the window.owner
property must not be properly set because the IE login prompt window appears behind the vscode app when running Login-AzureRmAccount
. Hope to see this fixed soon!
I can reproduce this with
Connect-AzureAD
from the AzureAD
module. Unlike what others say, I don't find the auth dialog behind the VSCode window. I eventually have to kill the Integrated Powershell Console.
This is an electron deficiency... I am sure I linked the appropriate issues somewhere...
Found it, we link to it from other issues, but not this one, so here's the vscode issue: https://github.com/Microsoft/vscode/issues/42356
@mmascolino my goto when PowerShell spawns a login is to look for the flashing PowerShell icon in the task bar.
Oddly enough...I don't see a flashing PowerShell icon either.
Yeah, coworker doesn't get flashing PowerShell when opening a file with a file open dialog. He is however able to find it with Alt+Tab...
I can repo the flashing with:
Get-ChildItem . | Out-GridView
but with the AzureAD commandlets that launch the multifactor auth popup window doesn't flash and I also don't find it with Alt-Tab
Also still a problem with:
Connect-AzAccount
It's not a great user experience when the very first thing you try and do in VS Code is to login and it doesn't work properly. I almost decided on abandoning using VSCode, before I realised what was going on. Please fix this!
@SydneyhSmith could we get this issue labeled with vscode-issue
as this is related to electron and there's nothing we can do?
Looking at the FAQ, would it be worth adding an entry to it? Perhaps something like:
**Q. Why is my window (Get-Credential, Connect-MsolService, Connect-AzAccount, Connect-AzureAd, etc) not appearing?**<br>
A. Due to an [issue](https://github.com/Microsoft/vscode/issues/42356) in electron, windows spawned by vscode do not appear above vscode.
@corbob - looks like electron also passed on owning this issue - they refer to using forcefocus
as a workaround.
It does seem to be a hard problem, but from a user experience perspective we could do better - maybe we can consider using forcefocus
in vscode for this use case. If this is your first user experience with vscode like @cbailiss - you are less likely to continue using the editor and shell as it doesn't work.
Visual Studio doesn't have any of these windowing issues, but it's also not electron-based.
I went ahead and updated the faq, thanks for providing the content @corbob
FWIW: I was working with Fluent Terminal and noticed that it appears to suffer from the same issue of windows spawned by PowerShell being behind it. The really complex part I think would be trying to sort out what windows are spawned by us and then using forcefocus
as @alohaninja alluded to.
Just chiming in that I'd also like this fixed. It's super annoying with out-gridview.
Hey, any progress on this? Seems like this issue still exists and hinders productivity.
Hey, any progress on this? Seems like this issue still exists and hinders productivity.
@B1T3X this appears to be an issue that is actually well beyond the scope of the extension. It's marked as a vscode issue, but in my experience it's actually a windows issue and is likely to always exist unless windows changes how it handles windows. This issue definitely happens under wezterm and windows terminal. The only terminal I have not seen exhibit this behaviour is conhost which is the old terminal built into windows.
I just tested this on: Windows 10 21H2 Windows terminal 1.11.2921.0 Az CLI 2.31.0 (with python 3.8.9) Default browser as Chrome 96.0.4664.93 (also default browser Edge 96.0.1054.43)
with an az login
command
and it works.
The edge or chrome window spawned on top of the terminal like it should.
I did do an Invoke-Item .
and the windows explorer window spawned behind terminal, so that test case is still valid.
Can someone mention the other test cases that cause windows to spawn behind the terminal? I'd like to gather them all together.
If the azure powershell module test case is still valid, let me know and i'll try to reproduce it. I'm hoping that if I can gather the use cases and reproduce all the scenarios, I can try to present these to the windows product team if it's a cmd/terminal issue. Then it should therefore be solved in vscode.
List of test cases:
Invoke-item .
Get-Process | Out-GridView
Looking into this a bit deeper, the issue is already being tracked elsewhere: https://github.com/microsoft/terminal/issues/2988 Maybe we should sync up there instead, as this issue isn't a vscode one.
@IanMoroney I just tested some use cases, here are the results: Windows PowerShell 5.1.19041.1320 Windows 10 21H2 (OS Build 19044.1387) Default browser: Microsoft Edge Version 96.0.1054.43 (Official build) (64-bit) Azure CLI 2.13.0 using Python 3.6.8
az login
did open a tab in my browser.
Connect-AzAccount
and Connect-AzureAD
opened a separate window behind VS code so I had to minimize VS Code to get to it. The separate window did not show up in the taskbar.
Connect-MsolService
also opened a separate window. but it showed up with the PowerShell icon in the taskbar and I could click it to focus it, so it's not quite the same behavior.
I dont see why this is a general windows problem. If I use this: get-process | out-gridview in different areas, I get these results: VSCode --> Grid-Window shows up in background Windows Powershell Console (5.1) --> Grid-Window shows up in foreground, correct ISE --> Grid-Window shows up in foreground, correct Powershell Core 7 Console --> Grid-Window shows up in foreground, correct Terminal Application --> Grid-Window shows up in background
For me it looks more like a shared component which does it wrong, which is used in vscode-extension + terminal? And it is a really annoying problem, if you work with VSCode the whole day, as it is a lot of clicking and it happens from time to time that you miss the "blinking" PS Window and wait and then realize that "someone is waiting on you".
It looks like Windows has an update to conpty that should fix this: https://github.com/microsoft/vscode/issues/42356#issuecomment-1346493056