ANSI Escape Sequence Handling Issue #16008

Closed
opened 2026-01-31 04:54:42 +00:00 by claunia · 6 comments
Owner

Originally created by @andrewraddatz on GitHub (Nov 30, 2021).

Windows Terminal version

1.12.211020001-release1.12

Windows build number

10.0.19041.0

Other Software

julia version 1.6 and above

Steps to reproduce

Launch julia inside of Windows Terminal

Expected Behavior

Launching julia outside of Windows Terminal with Legacy Console Mode enabled:

image

Windows Terminal should render the ANSI escapes as above.

Actual Behavior

When julia is launched in Windows Terminal, ANSI escapes are printed directly to the screen.

In Windows Terminal, launched from pwsh:
image

In Windows Terminal, launched from pwsh (julia --color=no):
image

In Windows Terminal, launched as a new tab:
image

In Windows Terminal, launched as a new tab (julia --color=no):
image

Launched directly, Legacy Console Mode disabled:
image

Originally created by @andrewraddatz on GitHub (Nov 30, 2021). ### Windows Terminal version 1.12.211020001-release1.12 ### Windows build number 10.0.19041.0 ### Other Software [julia](https://julialang.org/) version 1.6 and above ### Steps to reproduce Launch julia inside of Windows Terminal ### Expected Behavior Launching julia outside of Windows Terminal with Legacy Console Mode enabled: ![image](https://user-images.githubusercontent.com/58223683/144126754-2538a407-1c5d-4ac4-b25f-ec354aa06d93.png) Windows Terminal should render the ANSI escapes as above. ### Actual Behavior When julia is launched in Windows Terminal, ANSI escapes are printed directly to the screen. In Windows Terminal, launched from pwsh: ![image](https://user-images.githubusercontent.com/58223683/144127170-77c15ccb-db95-4d01-89f2-99e65eb94bc9.png) In Windows Terminal, launched from pwsh (julia --color=no): ![image](https://user-images.githubusercontent.com/58223683/144127263-4d91b42c-4a28-45af-a6f2-55a4cb0b7f0a.png) In Windows Terminal, launched as a new tab: ![image](https://user-images.githubusercontent.com/58223683/144127452-1cee1a35-f4ed-43f8-9d8d-e980ba112624.png) In Windows Terminal, launched as a new tab (julia --color=no): ![image](https://user-images.githubusercontent.com/58223683/144127536-de404fbb-0a66-4339-b001-456c3067fa2b.png) Launched directly, Legacy Console Mode disabled: ![image](https://user-images.githubusercontent.com/58223683/144127622-f6bc8114-215a-4f42-b85c-97f5c61f00f2.png)
Author
Owner

@zadjii-msft commented on GitHub (Nov 30, 2021):

(glad you made it from stackoverflow ☺️)

HUH. I wonder if they're setting the VT reg key.

Can you export the contents of HKCU\Console to a .reg file, rename it to .txt, and share it here?
image

I'm guessing that there's a VirtualTerminalLevel that's set to something other than 0, and they're using that to manually enable VT support, rather than using SetConsoleMode

@zadjii-msft commented on GitHub (Nov 30, 2021): (glad you made it from stackoverflow ☺️) HUH. I wonder if they're setting the VT reg key. Can you export the contents of `HKCU\Console` to a .reg file, rename it to `.txt`, and share it here? ![image](https://user-images.githubusercontent.com/18356694/144130899-2ab05ecc-eeb3-48ce-8a0e-1163d7eb4ac8.png) I'm guessing that there's a `VirtualTerminalLevel` that's set to something other than `0`, and they're using that to manually enable VT support, rather than using `SetConsoleMode`
Author
Owner

@andrewraddatz commented on GitHub (Nov 30, 2021):

Here's the output with a few non-relevant applications removed from the list.

console.txt

@andrewraddatz commented on GitHub (Nov 30, 2021): Here's the output with a few non-relevant applications removed from the list. [console.txt](https://github.com/microsoft/terminal/files/7629027/console.txt)
Author
Owner

@zadjii-msft commented on GitHub (Nov 30, 2021):

You know what, I'm smarter than that. When julia is working correctly, are you launching it from a shortcut? Something like julia.lnk, either on the desktop, or the Taskbar, or the Start Menu?

There are two places that a console app can have VirtualTerminalLevel set - one is in the registry, the other is in the lnk. Though, I didn't.... (thought clipped in favor of another theory)

Presumably, using the run dialog (win+r) to launch v:\PortableApps\julia\bin\julia.exe would also not work.

284257a383/src/host/srvinit.cpp (L194-L201)
We should be enabling virtual terminal processing for Terminal client apps, always. That implies that julia is actually _manually disabling it?!

f9bb6f8fa8/stdlib/REPL/src/LineEdit.jl (L1375)

That's the only SetConsoleMode reference in julia. Maybe there's something else I'm missing.

x-ref: https://github.com/JuliaLang/julia/issues/43273

PR that added the SetConsoleMode call: https://github.com/JuliaLang/julia/pull/36598

@zadjii-msft commented on GitHub (Nov 30, 2021): You know what, I'm smarter than that. When julia is working correctly, are you launching it from a _shortcut_? Something like `julia.lnk`, either on the desktop, or the Taskbar, or the Start Menu? There are two places that a console app can have `VirtualTerminalLevel` set - one is in the registry, the other is in the `lnk`. Though, I didn't.... (thought clipped in favor of another theory) Presumably, using the run dialog (<kbd>win+r</kbd>) to launch `v:\PortableApps\julia\bin\julia.exe` would _also_ not work. https://github.com/microsoft/terminal/blob/284257a38392c85a2f7d7ac7e77e20a05242ec64/src/host/srvinit.cpp#L194-L201 We should be enabling virtual terminal processing for Terminal client apps, _always_. That implies that julia is actually _manually disabling it?! https://github.com/JuliaLang/julia/blob/f9bb6f8fa8c66ca00f215cbbc4e4bc5addc43156/stdlib/REPL/src/LineEdit.jl#L1375 That's the only `SetConsoleMode` reference in julia. Maybe there's something else I'm missing. x-ref: https://github.com/JuliaLang/julia/issues/43273 PR that added the SetConsoleMode call: https://github.com/JuliaLang/julia/pull/36598
Author
Owner

@andrewraddatz commented on GitHub (Nov 30, 2021):

I don't launch it through a link. In Windows Terminal, the settings are done this way:

image
image

Otherwise, I use start v:\PortableApps\julia\bin\julia.exe to launch it.

@andrewraddatz commented on GitHub (Nov 30, 2021): I don't launch it through a link. In Windows Terminal, the settings are done this way: ![image](https://user-images.githubusercontent.com/58223683/144138873-5f516c31-01b7-4993-8f13-ad00787e5489.png) ![image](https://user-images.githubusercontent.com/58223683/144138961-fca06ffc-02eb-4173-a6cc-b0696bd24984.png) Otherwise, I use `start v:\PortableApps\julia\bin\julia.exe` to launch it.
Author
Owner

@andrewraddatz commented on GitHub (Nov 30, 2021):

After the problem magically resolving itself when i moved my ~/.julia directory, I did some more digging. It looks like the issue is tied to a macro that I created to clear the screen which was called in a different macro in my startup script.

replacing the macro with its content removes the ANSI character issue.

@andrewraddatz commented on GitHub (Nov 30, 2021): After the problem magically resolving itself when i moved my ~/.julia directory, I did some more digging. It looks like the issue is tied to a macro that I created to clear the screen which was called in a different macro in my startup script. replacing the macro with its content removes the ANSI character issue.
Author
Owner

@zadjii-msft commented on GitHub (Dec 1, 2021):

Well, that's good to know. Thanks for following up!

@zadjii-msft commented on GitHub (Dec 1, 2021): Well, that's good to know. Thanks for following up!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16008