Vscode-powershell: PowerShell Preview: Weird Behavior

Created on 25 Jan 2019  路  15Comments  路  Source: PowerShell/vscode-powershell

System Details


System Details Output

 & {"### VSCode version: $(code -v)"; "`n### VSCode extensions:`n$(code --list-extensions --show-versions | Out-String)"; "`n### PSES version: $($pseditor.EditorServicesVersion)"; "`n### PowerShell version:`n$($PSVersionTable | Out-String)"}
### VSCode version: 1.30.2 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8 x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 2.0.0.0

### PowerShell version:

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

Issue Description

I am experiencing a problem with... filename showing up in Console window on F5/CTRL+F5

preview problem1

While when there is some content output it will be removed when it's done, when there's no content (such as the .ps1 file has only function definition) it will look like on attached gif.

Area-PSReadLine Issue-Bug Preview Extension Resolution-Duplicate

Most helpful comment

What you're seeing here is few things:

  • when the script has defined a function and only that and you press F5 vscode will display filepath to Terminal

image

And it will stay like that.

  • when the script is run with F5 or CTRL+F5 PowerShell doesn't show it's running in a left bottom corner
  • when the script is run and you use a script block your output in the terminal will get mixed up with file path of an executed script
  • when the script is run it will sometimes display WARNING and other streams in weird places (like on the screenshot 2 posts up.

All 15 comments

Similar situation is here:

image

On production PowerShell:

image

This actually has a huge side effect.

Notice how this function uses scriptblock { } as a parameter and and then when uusing F5 or CTRL+F5 it takes whatever is displayed in the Terminal into tha script block (which in this case is file name). Only if use F6 (which in my case is Run Current File) it behaves as expected.

preview problem2

This makes it quite hard to work with.

Sorry for a bit of a delayed response but I am having trouble fully understanding what is happening here. Would you mind re-phrasing what the expected behavior is and what the current behavior is. Thanks as always!

What you're seeing here is few things:

  • when the script has defined a function and only that and you press F5 vscode will display filepath to Terminal

image

And it will stay like that.

  • when the script is run with F5 or CTRL+F5 PowerShell doesn't show it's running in a left bottom corner
  • when the script is run and you use a script block your output in the terminal will get mixed up with file path of an executed script
  • when the script is run it will sometimes display WARNING and other streams in weird places (like on the screenshot 2 posts up.

Let me try to explain this more simply.
This happens when "powershell.developer.featureFlags": [ "PSReadLine" ] is enabled.
If you run your saved script (with F5 for example), the script path will be written to the console (as before). the only difference is that it's not adding a "line break" after writing the path.

it's not cussing any "coding problem" but a "display" one. if your code don't have any output, after the code run you will be left with your text cursor on the start of the path line so if you write something you are writhing it on the path text overwriting it. or if your code have output it will do the same thing and write it's first output line on the path line so if the output is shorter then the path you will get a line with a mix of the two strings displayed.

So the solution is just to make it line break/move to the next line after writing the path. Exactly as on a regular Powershell windows you will writhe the file path and hit enter and as a result the text cursor moves down and only then the file output starts from there.

It looks like start without debugging needs to add a new line either after writing the file path or before output is written, thanks for reporting this!

Just FYI. It's still not working correctly in 2.0.1

Can also confirm that it is still a problem.
What is the point of releasing preview 2 to us if the bugs we reported on preview 1 are not addressed?

@ili101 preview.2 mostly contained work on the debugger. Sadly we couldn't get to everything this time around.

See also #1850

Is there a way to disable PSReadLine? In earlier versions, it was not enabled by default. Now it is, yet this issue is not fixed so it makes it really hard for me to cope with the output it provides.

Yes, you can do this in your settings:

powershell.developer.featureFlags: []

Ok so circling back here. This issue and https://github.com/PowerShell/vscode-powershell/issues/1850 are very closely related. In fact, they may be the same bug.

The file path showing up makes sense as an indicator that you are, in fact, running the script.

What's _not_ correct is that you _should_ be seeing a prompt _after_ that line, and you're not.

Making this a duplicate

This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.

Was this page helpful?
0 / 5 - 0 ratings