-
Notifications
You must be signed in to change notification settings - Fork 274
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
Fix garbled UCM prompt on Windows #3307
Fix garbled UCM prompt on Windows #3307
Conversation
Thank you @jesselooney! I don't have a Windows machine to test this on, but I can confirm that on my Debian machine this fixed an annoying issue that I believe had to do with the text width calculation. Before this PR, if I ran
After this PR it looks like one would expect:
I could see wanting to restrict this change to the prompt, but I also don't know the implications of not doing that. I'll leave that judgement for someone more familiar with haskeline and the UCM CLI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks for this! Really helpful to know that someone has tested this on Windows 👍🏼
Thanks @jesselooney! |
Here's what I'm seeing with the patch: Does this not happen for you, @jesselooney? Could you send a screenshot? |
I see none of that. That was from the VS Code terminal, and I also tested from Windows Terminal and plain old Command Prompt (shown below in that order). Command Prompt struggles with emoji and the colors are weird, but no issues that look like your screenshot. It's very strange that those escapes don't show at all for me. I do notice that my UCM prompt version reads In any case, I think there's still a simple fix: rename |
Overview
Fixes #3275
On Windows, the UCM prompt is corrected from this
[0m[32m.[0m> [0m
to this
.>
but there is still no color.
Implementation
This change appends the ASCII start-of-text (
\STX
) character within thetoANSI
andresetANSI
functions inside theUnison.Util.ColorText.toANSI
function, which should mean that every ANSI escape sequence rendered with that function should be followed immediately by this character. This is the recommended practice for haskeline, and most importantly should prevent the remainders of character control codes seen in issue #3275 from being displayed when haskeline removes the leading\ESC
character on Windows. This does not fix the lack of coloration of the UCM prompt on Windows, but it does stop the prompt from appearing garbled.While
\STX
is a control character and should not be rendered, I could see not wanting to insert them in every single placetoANSI
is used and instead just limiting this change to affect haskeline prompts. I didn't do that because it would require more work and the PR as it stands might be fine, but it could definitely be done.Additional notes
The issue of haskeline removing color codes on Windows is seemingly out of our control. See haskell/haskeline#130 for more information on the topic.
This change is