Skip to content
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

Clear-Host causes cursor position state issues with PSReadLine #2408

Closed
arcotek-ltd opened this issue Jan 10, 2020 · 3 comments · Fixed by PowerShell/PowerShellEditorServices#1162
Labels

Comments

@arcotek-ltd
Copy link

System Details

System Details Output

### VSCode version: 1.41.1 26076a4de974ead31f97692a0d32f90d735645c0 x64

### VSCode extensions:
[email protected]


### PSES version: 2.0.0.0

### PowerShell version:

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

Issue Description

Trying to get the directory of the current script using Split-Path -Path $PSScriptRoot -Parent.

Expected Behaviour

image
Running the same script in ISE gives the expected result.

Actual Behaviour

image

As you can see, in VSCode, the result is not the parent. It's returned the whole file.

I have tried other variations such as

$RootPath = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
$RootPath

# or

(Get-ChildItem -Path $PSScriptRoot).Parent

It always returns the full path.

Attached Logs

Follow the instructions in the troubleshooting docs
about capturing and sending logs.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Jan 10, 2020
@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Jan 10, 2020

Ok so this is a very interesting issue. For starters:

Your script is running properly and the Split-Path cmdlet is working fine

The problem here is purely visual output and is related to the PSReadLine support in the PS Integrated Console.

To prove it to you, you can do the following things:

  • hit ENTER until you start to scroll, then run the script again...
  • Restart the current session...
  • Enable the setting "powershell.integratedConsole.useLegacyReadLine": true and run it again
  • output everything from your script to a file using . { ... } > foo.txt

The bug shows up after you run Clear-Host so there's some state that PSReadLine & the PowerShell extension share that is not being updated properly.

@SydneyhSmith SydneyhSmith added Area-PSReadLine Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! labels Jan 10, 2020
@TylerLeonhardt TylerLeonhardt changed the title Split-Path -Path $PSScriptRoot -Parent returns file name Clear-Host causes cursor position state issues with PSReadLine Jan 10, 2020
@arcotek-ltd
Copy link
Author

Thanks for the reply @TylerLeonhardt.

I'm just trying your hypothesis, however, possibly related to this and #2407, pressing f5 has changed the prompt to:
image

Anyway, as you suggested, setting "powershell.integratedConsole.useLegacyReadLine": true resolved the issue, however, doskey (command history) doesn't work in debug mode, yet, IntelliSense does.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 11, 2020
@TylerLeonhardt
Copy link
Member

Yeah the prompt change is something I've noticed when doing console debugging in PowerShell as well so that's likely an issue there.

Did you try the first suggestion? Hitting enter until it scrolls? Curious if that works for you.

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

Successfully merging a pull request may close this issue.

2 participants