Skip to content

PowerShell Integrated Terminal Issue #1146

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
GHRoss opened this issue Jan 3, 2018 · 13 comments
Closed

PowerShell Integrated Terminal Issue #1146

GHRoss opened this issue Jan 3, 2018 · 13 comments

Comments

@GHRoss
Copy link

GHRoss commented Jan 3, 2018

System Details

  • Operating system name and version: MacOS High Sierra 10.13.2
  • VS Code version: 1.19.1
  • PowerShell extension version: 1.5.1
  • Output from $PSVersionTable:

PSVersion 6.0.0-rc.2
PSEdition Core
GitCommitId v6.0.0-rc.2
OS Darwin 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.3...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

1.19.1
0759f77bb8d86658bc935a10a64f6182c5a1eeba
x64
1 5 1 0

Issue Description

I am experiencing a problem with the integrated terminal.

I can run a script x amount of times in a row, and then try and type in the PowerShell Integrated Terminal which will return something like this: ^[[18;49R and will continue to do so until I clear the whole line, at which point I can start typing normally again, then the terminal is instantly unresponsive after executing a command resulting in having to kill the terminal and open a new one each time.

Attached Logs

log.txt

@rkeithhill
Copy link
Contributor

rkeithhill commented Jan 3, 2018

@GHRoss Thanks for taking the time to file this issue.

@tylerl0706 - we need to fix how we are determining the PS version on Linux/macOS. I've seen this error from a number of log files coming from macOS - including this one:

03/01/2018 18:21:57 [WARNING] - Method "GetVersionDetails" at line 153 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Session\PowerShellVersionDetails.cs

    Failed to look up PowerShell version, defaulting to version 5.
    
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.PowerShellContext.<>c__56`1.<ExecuteScriptAndGetItem>b__56_0(PSObject pso)
       at System.Linq.Enumerable.SelectIListIterator`2.MoveNext()
       at System.Linq.Enumerable.<OfTypeIterator>d__32`1.MoveNext()
       at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteScriptAndGetItem[TResult](String scriptToExecute, Runspace runspace, TResult defaultValue)
       at Microsoft.PowerShell.EditorServices.Session.PowerShellVersionDetails.GetVersionDetails(Runspace runspace, ILogger logger)

I'm not sure if that is causing the behavior that the OP sees but we should eliminate it. Not sure what problems defaulting to PS 5 on macOS might cause.

@TylerLeonhardt
Copy link
Member

@rkeithhill I'll look into it! Thanks @GHRoss for the issue!

@TylerLeonhardt
Copy link
Member

@GHRoss how are you running the script and what do you type in the Integrated Terminal?

@SeeminglyScience
Copy link
Collaborator

@tylerl0706 This is probably the same issue affecting debugging. That escape sequence is what is emitted to stdin when Console.CursorTop or Left is called on Unix platforms. There will always be a risk that that escape sequence will bleed into input (this risk is acknowledged via comments in corefx) But the pending PR should make it exceedingly rare and resolve the hanging.

@GHRoss If you're feeling adventurous and would like to give us a hand testing out the potential fix, here's the build from appveyor

@TylerLeonhardt
Copy link
Member

@SeeminglyScience That makes sense - and I agree with you. Do you think we should then close this as a dupe to one of the other issues? Or maybe add it to be resolved when finishing up PowerShell/PowerShellEditorServices#592

@TylerLeonhardt TylerLeonhardt removed their assignment Jan 4, 2018
@SeeminglyScience
Copy link
Collaborator

@tylerl0706 I'd like to leave it open to confirm it's the same issue, but I'm pretty sure so it's up to you.

Now that I think about it you may want to close the vscode-powershell issues I listed as resolved in that PR. I'm not a maintainer here so I'm not sure if they'll actually close automatically.

@rkeithhill
Copy link
Contributor

rkeithhill commented Jan 4, 2018

If they're listed in the PR (Fixes #<issue-number>) then they should close automatically when the PR is merged.

@TylerLeonhardt
Copy link
Member

Resolves #<issue> also seems to work too 🙂 on PowerShell/PowerShellEditorServices#592

@GHRoss
Copy link
Author

GHRoss commented Jan 4, 2018

@rkeithhill Good spot.

@tylerl0706 I run the script by pressing F5 and then any key on the keyboard will give me the unexpected output.

@SeeminglyScience I think you're right, I cannot currently debug on macOS without hitting a key between each step. Where would I put the contents of that zip file to test, please? I'm excited to see this (potentially) fixed, after hours of wasted opening and closing of the terminal!

@SeeminglyScience
Copy link
Collaborator

@GHRoss The easiest way is to replace the contents of the PowerShellEditorServices folder in you extension folder with the contents of the one in this zip. More specifically:

  1. In the integrated console, type ii ((gmo PowerShellEditorServices.Commands).ModuleBase|Split-Path). That should open the PSES folder within the extension in your file explorer.

  2. Make sure all instances of VSCode are closed

  3. Copy the contents of the PowerShellEditorServices folder from the zip into the window opened in step 1

  4. If you get access denied errors, try running gps pwsh|? id -ne $pid|spps in a separate PowerShell window

@GHRoss
Copy link
Author

GHRoss commented Jan 4, 2018

I can confirm that this has fixed all of my issues. Overjoyed!

Couldn't get the terminal to crash even if I tried!

@SeeminglyScience
Copy link
Collaborator

@tylerl0706 another issue I missed in the PR

@TylerLeonhardt
Copy link
Member

Closing :)

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

No branches or pull requests

4 participants