Skip to content

conhost.exe console windows on Windows: cmdlets, e.g. Select-String, do not render VT (ANSI) escape sequences in their for-display output with direct input from native (external) programs  #20898

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

To recap the repro steps: The problem occurs:

  • on Windows
  • in regular console windows (conhost.exe), not in Windows Terminal
    • with the VirtualTerminalLevel registry value in key HKEY_CURRENT_USER\Console NOT manually set to 1, i.e. either set to 0 or - as is the default - with the value not defined.
  • with input from external programs
# From a conhost.exe console window on Windows,
# with the defaults (see note re `VirtualTerminalLevel` above).
cmd /c echo foo | Select-String f

Suboptimal workarounds:

Suspected cause, quoting @SeeminglyScience from #18294 (comment):

I would guess it's related to #16612 but I've looked it over and I can't easily see how. We should be re-enabling VT more often rather than less, so something is a little off for sure. /cc @daxian-dbw

Expected behavior

foo

with f inverted, to highlight the matching part of the line.

Actual behavior

←[7mf←[0moo

That is, the VT escape sequence weren't rendered.

Error details

No response

Environment data

PowerShell 7.4.0 on Windows 11 22H2

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions