vscode-powershell
vscode-powershell copied to clipboard
powershell.integratedConsole.focusConsoleOnReadHost feature request
Prerequisites
- [X] I have written a descriptive issue title.
- [X] I have searched all open and closed issues to ensure it has not already been reported.
- [X] I have read the troubleshooting guide.
- [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- [X] If this is a security issue, I have read the security issue reporting guidance.
Summary
In Visual Studio Code (VSC) I have set powershell.integratedConsole.focusConsoleOnExecute to true.
When debugging a PowerShell script in VSC, when execution reaches line that requests user input (e.g., Read-Host), the focus does not automatically move to the console. Instead, it remains in the editor pane, with the current debug break point line selected. If I don't notice the focus is still in the editor pane, and start typing my input, it erases the selected code line (i.e., the call to Read-Host).
PowerShell Version
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
code --version
1.81.0
6445d93c81ebe42c4cbd7a60712e0b17d9463e97
x64
Extension Version
code --list-extensions --show-versions | Select-String powershell
[email protected]
Steps to Reproduce
STEPS TO REPRODUCE
In a PowerShell script in Visual Studio Code, set a break point on a line that calls Read-Host.
Launch a debug session, and run to the break point.
Step over the line.
EXPECTED RESULT: Focus automatically shifts to the console so the user can provide the input.
ACTUAL RESULT: The focus stays in the editor pane. If the user doesn’t notice that the focus hasn’t moved, and starts typing, his input erases the current selection in the editor pane: In this case, the line of code with the Read-Host call.
Visuals
No response
Logs
8/8/2023 11:50:59 AM [NORMAL] - Visual Studio Code: v1.81.0 64-bit on Windows 64-bit 8/8/2023 11:50:59 AM [NORMAL] - PowerShell process started with PID: 4496 8/8/2023 11:50:59 AM [NORMAL] - Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe 8/8/2023 11:50:59 AM [NORMAL] - PowerShell Extension: v2023.6.0 8/8/2023 11:51:02 AM [NORMAL] - Started PowerShell v7.3.6. 8/8/2023 11:51:03 AM [NORMAL] - PowerShell is up-to-date. 8/8/2023 12:24:18 PM [VERBOSE] - Settings changed, prompting to restart... 8/8/2023 12:25:00 PM [VERBOSE] - Already started. 8/8/2023 12:25:00 PM [VERBOSE] - Session status changing from 'Running' to 'Busy'. 8/8/2023 12:25:00 PM [VERBOSE] - Connecting to pipe: \.\pipe\PSES_r0oi1aqw.m3t 8/8/2023 12:25:00 PM [VERBOSE] - Debug configuration: { "name": "PowerShell: Launch Current File", "type": "PowerShell", "request": "launch", "script": "C:\Users\Dick\Documents\WebPublisher\WebPublisher.ps1", "args": [ "set-client-root" ], "__configurationTarget": 6, "internalConsoleOptions": "neverOpen", "createTemporaryIntegratedConsole": false }
Thanks @aksarben for your issue, and thanks for providing detailed information and repro steps...what you are asking for sounds like a new feature request, to switch focus when user input is requested from the console...I will mark this as up for grabs...thanks!
Some clarification on my ticket. I mistakenly said "console" instead of "terminal." And I discovered the problem only appears when in the debugging mode. When run outside the debugger, the feature works as you would expect.
So, IMHO, this is more of a bug report than a feature request.
Also, since I entered the ticket, a new clue appeared. While I was using VSC a dialog suddenly popped open with the error message: PowerShell Language Server process didn't start! Don't know if this related to the focus-change issue, or if it's a separate problem.
For your consideration…
The Cyber Hymnal™ <>< http://www.hymntime.com/tch
From: Sydney Smith @.> Sent: Wednesday, August 9, 2023 2:25 PM To: PowerShell/vscode-powershell @.> Cc: Dick Adams @.>; Mention @.> Subject: Re: [PowerShell/vscode-powershell] powershell.integratedConsole.focusConsoleOnExecute Flag Not Working (Issue #4691)
Thanks @aksarbenhttps://github.com/aksarben for your issue, and thanks for providing detailed information and repro steps...what you are asking for sounds like a new feature request, to switch focus when user input is requested from the console...I will mark this as up for grabs...thanks!
— Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/vscode-powershell/issues/4691#issuecomment-1672019019, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPYO6QOQC44FB3TWIHFHEDXUPP3RANCNFSM6AAAAAA3IZXSMA. You are receiving this because you were mentioned.Message ID: @.***>
@aksarben, as for "console" vs. "terminal": The terminology confusion is unfortunate, but both terms apply: the setting is for the PowerShell Integrated Console, which runs in Visual Studio Code's integrated terminal.
(Dialogs popping up, as now shown in your related Stack Overflow question are most likely an unrelated problem.)
As for your original report:
The current behavior is possibly by design (I can't speak to that):
- The setting is effective when debugging starts: the input focus moves to the integrated terminal...
- ... and stays there (even after debugging ends) UNLESS a breakpoint is hit, in which case the focus moves back to the editor pane and stays there.
Why would you want the focus to move back to the editor when a breakpoint is hit? Here are a few reasons (there may be more):
- Hovering over variables to show their current value only works if the editor has the focus.
- Keyboard shortcuts such as F12 to jump to a variable's definition only work if the editor has the focus.
- You may want to edit the line with the breakpoint or other lines nearby (even though such changes don't take effect in the same debugging session).
De facto, users may have come to expect and rely on this behavior, so changing it would be problematic, I think.
A non-breaking option - which would indeed make this a feature request - would be to change the setting from a Boolean to an integer, where, say, 2 could signal the intent to place the focus in the integrated terminal and leave it there, even when breakpoints are hit.
PowerShell Language Server process didn't start! Don't know if this related to the focus-change issue, or if it's a separate problem.
This would be a separate issue