Skip to content
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

Update Windows ANSI code code based on feedback #543

Merged
merged 1 commit into from
Mar 13, 2025

Conversation

jakebailey
Copy link
Member

return
}
fileType, err := windows.GetFileType(h)
if err != nil || fileType == windows.FILE_TYPE_CHAR {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's worth noting that you need to do this to only enable virtual terminal processing if stdout hasn't been redirected. Otherwise, leave it as-is.

Copy link
Member

Choose a reason for hiding this comment

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

Or it's possible you don't even "need" to do it? It's unclear to me what the purpose is since libuv doesn't do this.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's worth noting that you need to do this to only enable virtual terminal processing if stdout hasn't been redirected. Otherwise, leave it as-is.

The STD_OUTPUT_HANDLE is not redirected if it is a character device and GetConsoleMode succeeds. See for example dotnet's IsHandleRedirected function.

Or it's possible you don't even "need" to do it? It's unclear to me what the purpose is since libuv doesn't do this.

It is optional. I suggested this change to @jakebailey because GetConsoleMode can be slow, and GetFileType (which is much faster), helps doing the GetConsoleMode only when it is really necessary. Having said this, as enableVirtualTerminalProcessing is a one-time call, it won't make any difference.

@jakebailey jakebailey added this pull request to the merge queue Mar 13, 2025
Merged via the queue into main with commit 4170b5d Mar 13, 2025
18 checks passed
@jakebailey jakebailey deleted the jabaile/update-windows-console branch March 13, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants