New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSDefaultParameterValues on Get-Help for ShowWindow triggers help window on mouse over of cmdlet #2121
Comments
So I was thinking it would be a simple addition to here: https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Language/CommandHelpers.cs#L88-L90 whereby we add a parameter of |
@jrich523 thanks for opening this issue, are you able to provide us with a screen shot so we can better understand the issue? Thanks! |
@SydneyhSmith here's a gif of the issue (hopefully it makes sense). Notice when mousing over I'm fairly certain the code that's causing it is https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Language/CommandHelpers.cs#L88-L90, however as this would only be an issue in Windows PowerShell and possibly PowerShell 7 (if @jrich523 as another workaround: in your profile, you could look at |
@corbob thanks for the excellent gif and explanation...we agree that that is likely the best way forward...I'll mark this as up for grabs in case anyone has some time to tackle this issue |
@SydneyhSmith and @corbob There is a broader issue that is worth addressing here that I've run into a number of times, and that you'll probably run into again if you don't address it properly.
Other preference variables such as Command and variable breakpoints can and will impact tools that internally invoke PowerShell if tool authors are not careful. For example, in VS Code, invoke this: Solving these problems is not trivial because PowerShell itself does not do a great job making it easy to solve these problems. PowerShell needs the following so that tools can be written and used as black boxes:
I'll open issues for those in PowerShell/PowerShell, but in the meantime you should consider having an internal helper method that protects against this, by doing all of the following:
I think that covers most if not all of what you should be thinking about here. If you have any questions, let me know. |
When I posted this issue in the PowerShell repo, @BrucePay raised a good question:
If the PowerShell commands you are invoking are not dependent on the state of the current runspace, nor on modules loaded in the current runspace, then that would be a great solution to this problem, because the runspace you use for "internal" commands would never pick up on user preference variables or state. In the case of the OP on this issue, invoking Get-Help in a separate, internal runspace would avoid the problem entirely, and you'd never have to worry about It's been a little while since I worked on PowerShell tools though, but my gut says that while this approach would solve some problems, for PowerShell tools there is still the broader problem of working with PowerShell when you want to work with data in the user's runspace (getting variable values, etc.). For those cases, using the SDK without invoking any PowerShell would be the best alternative. If vscode-powershell has PowerShell commands that it needs to invoke in the current user's runspace that perform tasks that are not supported by the SDK, that would be very good to know. |
That would miss help from commands that were loaded from:
It would also use a different help cache which would (slightly) hurt performance.
If we're invoking PowerShell then we pretty much always need state. That said, the integrated console is a special case. Most SDK consumers won't need to share a runspace with an active prompt. I imagine most will completely own their runspace, and probably won't even invoke the user's |
Thanks @SeeminglyScience, that's what I thought. The separate runspace idea seemed to simple, and for PowerShell tools like this (and PowerGUI and PowerWF and PowerSE in the past, which all had this same challenge), runspace state is central to what those tools do, in which case it is better to work around the problem where possible, perhaps using something like the method logic I shared earlier, while moving the PowerShell SDK forward to support such things in a native way. |
System Details
$PSVersionTable
Name Value
PSVersion 5.1.17134.858
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.858
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
With the following set, i get a help window pop up on mouse over of cmdlets/functions
$PSDefaultParameterValues.'Get-Help:ShowWindow' = $true
Expected Behaviour
Nothing
Actual Behaviour
Help window pops up
Attached Logs
event log that triggers it:
The text was updated successfully, but these errors were encountered: