question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ANSI Escape Code received from the SSH from the Linux's BASH breaks the output in the PowerShell Integrated Console

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

I wrote a very simple script to execute the ssh command on the Raspberry Pi OS. When I run this script from the new Windows Terminal (with pwsh) or the integrated VSCode terminal (with pwsh), everything works fine. The problem only occurs when I run this script via PowerShell Integrated Console. ssh is configured with Key-Based Authentication. The problem is that the script output in PowerShell Integrated Console is broken. In my opinion PowerShell Integrated Console does not remove or convert ANSI Escape Code properly. Which results in the destruction of the result text.

While generating the logs, I disabled all extensions except PowerShell.


VSCode does not recognize this setting. Therefore, I do not provide this log. Provide Language Server Protocol payload logs: "powershell editor services.trace.server":"verbose"


This result is also empty:

PS C:\Users\michal> $psEditor.EditorServicesVersion
PS C:\Users\michal>

Below, in the logs section, I attach the logs, my VSCode settings and the script.

PowerShell Version

PS C:\Users\michal> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.4
PSEdition                      Core
GitCommitId                    7.1.4
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

PS C:\Users\michal> code --version
1.60.0
e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
x64

Extension Version

PS C:\Users\michal> code --list-extensions --show-versions
funkyremi.vscode-google-translate@1.4.13
golang.go@0.27.2
liviuschera.noctis@10.40.0
ms-python.python@2021.9.1191016588
ms-python.vscode-pylance@2021.9.0
ms-toolsai.jupyter@2021.8.2031190714
ms-toolsai.jupyter-keymap@1.0.0
ms-vscode-remote.remote-ssh@0.65.7
ms-vscode-remote.remote-ssh-edit@0.65.7
ms-vscode.cpptools@1.6.0
ms-vscode.powershell@2021.8.2
njpwerner.autodocstring@0.5.4
SanaAjani.taskrunnercode@0.3.0

Steps to Reproduce

  1. Configure any Debian OS (with BASH) and turn on the ssh server on it
  2. Open VSCode with PowerShell extension on Windows
  3. Save this source to file and edit it with VSCode:
# Windows 10; PowerShell 7.1.4
# Build and run the example program on the `Raspberry Pi Computer`

ssh pi @"
hostname
date
"@
  1. Run this script as file in the PowerShell Integrated Console so that Linux returns you the result as when calling a normal ssh command

pi hostname doesn’t matter

Visuals

bug

Logs

EditorServices.log StartEditorServices.log vscode-powershell.log


BuildAndRun.ps1.txt settings.json.txt


VS Code version: Code 1.60.0 (e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff, 2021-09-01T10:41:52.311Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No

System Info
Item Value
CPUs AMD Ryzen 7 3800X 8-Core Processor (16 x 3893)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.95GB (26.05GB free)
Process Argv –crash-reporter-id 115d5e1c-df42-47e2-8ae1-76ba0eec26f0
Screen Reader no
VM 0%
Extensions (1)
Extension Author (truncated) Version
powershell ms- 2021.8.2
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30300192
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
pythonvsuse255:30340121
vscod805:30301674
pythonvspyt200:30340761
vscextlang:30333561
binariesv615:30325510
vsccppwtct:30329789
pythonvssor306:30344512
bridge0708:30335490
pygetstartedt2:30360495
bridge0723:30353136
pythonf5test824:30361777
javagetstartedt:30351793
vsdyn420:30356812
pydsgsc2:30361791
vscus224:30358039

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
michal037commented, Oct 29, 2021

Hello, I confirm that the problem does not occur in version v2021.10.3-preview.

https://user-images.githubusercontent.com/7441419/139356187-f061966f-68f7-40b0-8f7f-37d20a286ea5.mp4

1reaction
andschwacommented, Oct 29, 2021

Hello, and thank you for your patience! The latest PowerShell Preview for VS Code is now out, and includes the reworking of our pipeline and threading architecture in https://github.com/PowerShell/PowerShellEditorServices/issues/1295. Could you verify if this issue still reproduces using v2021.10.3-preview? 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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

about ANSI terminals - PowerShell | Microsoft Learn
Describes the features of PowerShell that use ANSI escape sequences and the terminal hosts that support them.
Read more >
Using ANSI Escape Sequences in PowerShell - — duffney.io
The escape character is used to indicate the beginning of a sequence and changes the meaning of the characters that follow the escape...
Read more >
Frequent 'ansi-escape' Questions - Stack Overflow
ANSI escape code (or escape sequences) is the method of in-band signaling to control formatting, color, and other output options on video text...
Read more >
Removing ANSI color codes from text stream - Super User
Not an answer to the question, but you can also pipe the output to more or less -R which can interpret the escape...
Read more >
Terminal Shell Integration in Visual Studio Code
Supported shells: Linux/macOS: bash, pwsh, zsh; Windows: pwsh. Installation. Automatic script injection. By default, the shell ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found