Skip to content

Implement LengthInBufferCells to fix ANSI formatting #1571

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

Conversation

SeeminglyScience
Copy link
Collaborator

Without redirecting this call to internalRawUI any formatting with ANSI escapes will likely be truncated in the wrong spot.

Before fix

image

After fix

image

Fixes #840

Without redirecting this call to `internalRawUI` any formatting with
ANSI escapes will likely be truncated in the wrong spot
Copy link
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how we could test this 🤔

@andyleejordan andyleejordan changed the title Add LengthInBufferCells implementation Implement LengthInBufferCells to fix ANSI formatting Sep 7, 2021
@andyleejordan andyleejordan merged commit 8c62e0e into PowerShell:master Sep 7, 2021
@andyleejordan
Copy link
Member

Thanks @SeeminglyScience!!!

@andyleejordan
Copy link
Member

Just because it relates to ANSI escape stuff...any chance this could fix PowerShell/vscode-powershell#3543? I don't know which escape character is being sent in that instance.

@ghost
Copy link

ghost commented Sep 7, 2021

Just because it relates to ANSI escape stuff...any chance this could fix PowerShell/vscode-powershell#3543? I don't know which escape character is being sent in that instance.

If you have any idea how to read it, I'll send you additional logs.

@SeeminglyScience
Copy link
Collaborator Author

SeeminglyScience commented Sep 7, 2021

I wonder how we could test this 🤔

Yeah that's a tough one. Any test I can think of is too arbitrary since we can't really utilize TerminalHost* atm. Even if we could all we could really do is verify that it just proxies the call. Even trying to test that it returns the expected length seems a bit odd because then we're really testing ConsoleHost* instead.

Just because it relates to ANSI escape stuff...any chance this could fix PowerShell/vscode-powershell#3543? I don't know which escape character is being sent in that instance.

Probably not. Kind of wonder if it might be something in termios that needs to be set. A before and after of stty --all might be helpful there.

I know input being messed up after wards probably makes that hard, but something like this might work:

& {
    stty --all
    ssh pi @"
hostname
date
"@
    stty --all
}

@andyleejordan
Copy link
Member

LMAO the body of this PR found an unhandled edge case in the release scripts and caused the number in the changelog for this entry to be 24977523 instead of 840.

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

Successfully merging this pull request may close these issues.

Table width not calculated correct when using VT100
2 participants