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

built-in powershell terminal emits control characters when the paths are long #212130

Open
bcullman opened this issue May 6, 2024 · 4 comments
Open
Assignees
Labels
confirmation-pending terminal-shell-pwsh An issue in the terminal specific to PowerShell

Comments

@bcullman
Copy link

bcullman commented May 6, 2024

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.89.0
  • OS Version: Windows 10 Enterprise 22H2

Steps to Reproduce:

  1. Create ps1 file. It can be simple, and named anything. Mine is test.ps1.
Write-Output "Test script running."
  1. Create some dummy files. They can be simple, and named anything. Mine are anytext1.txt and anytext2.txt
  2. Place the files at c:\
  3. Run the ps1 file in the powershell terminal inside vs code. Try passing files as parameters too.
PS C:\> .\test.ps1
Test
script
running.

PS C:\> .\test.ps1 -filepath1 "anyfile1.txt" -filepath2 "anyfile12.txt"                                                               
Test                                                                                                                                  
script
running.

These look correct

  1. now move (or create a copy of) the files into a deep directory (or create your own). Run the ps1 file in the powershell terminal inside vs code. Again, try passing files as parameters too.
PS C:\> .\Level1\Level2\Level3\Level4\Level5\Level6\Level7\Level8\Level9\test.ps1 
Test
script
running.

PS C:\> .\Level1\Level2\Level3\Level4\Level5\Level6\Level7\Level8\Level9\test.ps1  -filepath1 "C:\Level1\Level2\Level3\Level4\Level5\Level6\Level7\Level8\Level9\anyfile1.txt"
63-b542a92b556dTest
script
running.

> .\Level1\Level2\Level3\Level4\Level5\Level6\Level7\Level8\Level9\test.ps1  -filepath1 "C:\Level1\Level2\Level3\Level4\Level5\Level6\Level7\Level8\Level9\anyfile1.txt" -filepath2 "C:\Level1\Level2\Level3\Level4\Level5\Level6\Level7\Level8\Level9\anyfile12.txt" 
el1\x5cLevel2\x5cLevel3\x5cLevel4\x5cLevel5\x5cLevel6\x5cLevel7\x5cLevel8\x5cLevel9\x5canyfile12.txt";86b66494-a1e9-4bfb-b163-b542a92b556dTest
script
running.

note the "63-b542a92b556d" emitted in the 2nd instance, and "el1\x5cLevel2\x5cLevel3\x5cLevel4\x5cLevel5\x5cLevel6\x5cLevel7\x5cLevel8\x5cLevel9\x5canyfile12.txt";86b66494-a1e9-4bfb-b163-b542a92b556d" emitted in the 3rd instance

The first response looks ok, but as we add parameters with long paths, we start getting more and more control characters emitted to the console

Some observations:

  • This does not happen in standalone Windows PowerShell, Windows Terminal PowerShell, or PowerShell_ISE. This only happens in the PowerShell terminal inside of VS code.
  • What the ps1 files executes does not matter
  • The content in the files used as parameters does not matter
  • This seems to be driven by the length and/or amount of paths being used here.
  • This is present in the insider preview
@meganrogge
Copy link
Contributor

maybe related #211922

did this just start happening for you?

@bcullman
Copy link
Author

bcullman commented May 7, 2024

maybe related #211922

I don't think so. The path's in my example do not contain any special characters. I am also not using starship

did this just start happening for you?

I only recently started working with powershell scripts that were a) deeply nested, and b) required their own lengthly paths as parameters.

But I have been dealing with other powershell scripts with lengthy parameter lists and values and had not seen this behavior. it seems limited to when long paths are involved.

@meganrogge meganrogge added terminal-shell-pwsh An issue in the terminal specific to PowerShell confirmation-pending labels May 7, 2024
@bcullman
Copy link
Author

bcullman commented May 8, 2024

@meganrogge , @Tyriar

I think this is related to #210353

@tylerschmidtjp
Copy link

@bcullman @meganrogge @Tyriar

I just posted this on #210353, but in 1.89, as a workaround i replaced ~\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1 with the shellIntegration.ps1 from commit 1e790d7 and it resolves the issue.

Sorry I can't dig in further and help -- if I have time I'll try building VS code on my personal PC and see if I can help pinpoint it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmation-pending terminal-shell-pwsh An issue in the terminal specific to PowerShell
Projects
None yet
Development

No branches or pull requests

4 participants