Skip to content

Debug Session Clutters Terminal Command History #873

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

Closed
mike-the-automator opened this issue Jun 13, 2017 · 15 comments
Closed

Debug Session Clutters Terminal Command History #873

mike-the-automator opened this issue Jun 13, 2017 · 15 comments
Assignees
Labels

Comments

@mike-the-automator
Copy link

System Details

  • Operating system name and version:
  • VS Code version:
  • PowerShell extension version:
  • Output from $PSVersionTable:


PS C:\Temp> code -v
1.13.0
376c52b955428d205459bea6619fc161fc8faacf
PS C:\Temp> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      3      2      0


PS C:\Temp> code --list-extensions --show-versions
ms-vscode.PowerShell@1.3.2
ms-vsts.team@1.118.2
PS C:\Temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.1198
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.1198
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with commands being inserted into the command history by a debugging session. The additional commands seem to be related to the debugging session. I have reproduced this issue with a simple .ps1 file containing a single variable assignment, with a breakpoint set on the line.

Repro.ps1:
$x=1

The entires I'm referring to are Ids 5-9 in the below transcript. The "Get-Variable" entries in the command history appear to be triggered by hovering the mouse over a variable in the editor window to view its value. I'm not sure what triggers the ones.

PS C:\Projects\SQLServerDBA\PowerShellModulesV2> c:\Temp\repro.ps1


PS C:\Temp> get-history

  Id CommandLine
  -- -----------
   1 get-module
   2 gci c:\temp\
   3 c:\Temp\repro.ps1


PS C:\Temp> c:\Temp\repro.ps1



Hit Line breakpoint on 'C:\Temp\repro.ps1:1'

[DBG]: [DBG]: PS C:\Temp>
PS C:\Temp> Get-history

  Id CommandLine
  -- -----------
   1 get-module
   2 gci c:\temp\
   3 c:\Temp\repro.ps1
   4 get-history
   5 @{ 'computerName' = $env:ComputerName; 'processId' = $PID; 'instanceId'...
   6 Get-Variable
   7 Get-Variable
   8 $global:__psEditorServices_CallStack = Get-PSCallStack; $global:__psEdi...
   9 Get-Variable
  10 c:\Temp\repro.ps1

@daviwil daviwil added Area-Debugging Issue-Bug A bug to squash. labels Jun 13, 2017
@daviwil daviwil added this to the June 2017 milestone Jun 13, 2017
@daviwil
Copy link
Contributor

daviwil commented Jun 13, 2017

Thanks Mike! This is coming from PowerShell, I had filed a bug on it some time ago:

PowerShell/PowerShell#3109

I'll see if I can find a workaround that doesn't cause these commands to be added to your history.

@daviwil daviwil modified the milestones: June 2017, July 2017 Jul 11, 2017
SeeminglyScience added a commit to SeeminglyScience/PowerShellEditorServices that referenced this issue Oct 4, 2017
This change fixes an issue where background commands would be added
to PowerShell's history.  This was due to a limitation in the
PowerShell debugger where the only way commands are excluded is if
the command is part of a hard coded set of commands. As a workaround,
a command from that set (prompt) is added as the first statement.

Resolves PowerShell/vscode-powershell#873
@daviwil daviwil modified the milestones: July 2017, Future Oct 26, 2017
@JustinGrote
Copy link
Collaborator

JustinGrote commented Apr 22, 2020

@SydneyhSmith @TylerLeonhardt
EDIT: Can Reproduce now:
image

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 22, 2020
@SeeminglyScience
Copy link
Collaborator

Get-History is still dirty FWIW. Until an option is added to the debugger API to skip adding to history, there won't really be a good way to fix that though :/

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 23, 2020
@SydneyhSmith SydneyhSmith removed this from the Future milestone Jan 26, 2021
@TheOnlyWei
Copy link

Any updates on this? Just wasted a few hours debugging a Start-Transcript call in my code only to realize that the strange logs was caused by the debugger itself from the VS Code PowerShell extension.

@andyleejordan
Copy link
Member

Um, well, it is fixed in the preview as of right now, but our fix might not be viable long-term. Give the preview a try!

@andyleejordan andyleejordan moved this to Todo in Sea Biscuit Mar 31, 2022
@andyleejordan andyleejordan moved this from Todo to In Progress in Sea Biscuit Apr 4, 2022
@andyleejordan
Copy link
Member

@TheOnlyWei Did you get a chance to try the Preview?

@JustinGrote JustinGrote added the Needs: Fix Verification Please verify the fix for us! label Apr 5, 2022
@TheOnlyWei
Copy link

TheOnlyWei commented Apr 5, 2022

@andschwa The 7.3-preview does not seem to list this fix in the change description. I switched VS code integrated console to PowerShell Core 7.3-preview anyway and it didn't fix anything. Did it work for you on your machine?

@andyleejordan
Copy link
Member

The latest code is available in the PowerShell Preview for VS Code, and includes a myriad of fixes. Could you verify if this issue still reproduces using the preview extension? Please note that this preview is likely to include other bugs, and you should feel free to file new issues for those so we can work through them. Thanks again!

@andyleejordan
Copy link
Member

@TheOnlyWei See my reply above, I meant the preview of the extension, not PowerShell's preview version itself (sorry for the confusion). Thanks!

@TheOnlyWei
Copy link

@andschwa The output clutter is greatly reduced, but still getting some stuff like the following that is not output in the console:

PS>CommandInvocation(Get-Variable): "Get-Variable"
>> ParameterBinding(Get-Variable): name="Scope"; value="Global"
PS>CommandInvocation(Get-Variable): "Get-Variable"
>> ParameterBinding(Get-Variable): name="Scope"; value="Script"
PS>CommandInvocation(Get-Variable): "Get-Variable"
>> ParameterBinding(Get-Variable): name="Scope"; value="Local"
PS>CommandInvocation(Get-Variable): "Get-Variable"
>> ParameterBinding(Get-Variable): name="Scope"; value="Local"

@andyleejordan
Copy link
Member

Ah! Thanks @TheOnlyWei, can definitely fix the rest of this!

@andyleejordan andyleejordan removed the Needs: Fix Verification Please verify the fix for us! label Apr 12, 2022
@andyleejordan andyleejordan moved this from In Progress to Todo in Sea Biscuit Apr 12, 2022
@andyleejordan andyleejordan self-assigned this Apr 12, 2022
@andyleejordan
Copy link
Member

Well, that's interesting. I'm actually not sure why those last bits are showing up, as the default for AddToHistory is false, so they shouldn't be.

@andyleejordan
Copy link
Member

Going to leave this one open to track the remaining work.

@andyleejordan
Copy link
Member

Hey @TheOnlyWei can you test the latest release and let me know both what you see and how you test it? I'd like to get this finished if I can.

@SydneyhSmith SydneyhSmith moved this from Wishlist to In Progress in American Pharoah Sep 6, 2022
@SydneyhSmith
Copy link
Collaborator

Closing this as resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

7 participants