Skip to content

Underline not rendered after some SGR 22/39/49 #3076

Closed

Description

Environment

Windows build number: Win32NT 10.0.18362.0
Windows Terminal version (if applicable): 0.5.2762.0

Steps to reproduce

echo -e '\e[4m underlined \e[33m yellow \e[39m should still be underlined \e[m'

Expected behavior

The entire line should be underlined.

Actual behavior

The "should still be underlined" bits aren't underlined.

Note that SGR codes 22, 27, 39 and 49 seem to cause this effect, but only if they're predeced by a 1, 7, 30-37 or 40-47, resp., that is, only if they do actually turn off some other attribute.

Also note that if the "should still be underlined" text is made longer so that it overflows to the next line (or even multiple new lines), it's underlined in the last one of these lines. This makes it perhaps a reincarnation of #47.

Furthermore, changing the window width and thus causing a reflow of the text removes the underlining from the last line.

Activity

  1. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Oct 5, 2019
  2. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Oct 5, 2019
  3. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Oct 6, 2019
  4. DHowett-MSFT commented on Oct 6, 2019

    @DHowett-MSFT
    Contributor

    Investigation yields that the attributes are read & stored correctly; next step is looking at VtEngine (ConPTY out).

  5. DHowett-MSFT commented on Oct 6, 2019

    @DHowett-MSFT
    Contributor

    VtEngine::_RgbUpdateDrawingBrushes doesn't factor in any attributes other than bold & color (actual RGB value) when it decides to emit \e[m. This is something that'll probably be addressed by #2661, which suggests that we should defer converting attributes into RGB values (and other unpacked flags) as late as possible.

  6. DHowett-MSFT commented on Oct 6, 2019

    @DHowett-MSFT
    Contributor

    I'm keeping this one open as a linked workitem. Thanks for finding this, Egmont Koblinger (@egmontkob)!

  7. aeiplatform commented on Oct 6, 2019

    @aeiplatform

    Since echo -e is not POSIX compliant, you should rather combine printf and tput for text formatting.
    In POSIX echo acts like echo -e by default but not in bash, because of arguments expansion.

    I guess this command for my current bash works as expected.
    (GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)).
    image

    In POSIX this would be equivalent for yours example:
    printf "%s underline %s yellow %s should still be underlined %s\n" "$(tput smul)" "$(tput setaf 3)" "$(tput setaf 7)" "$(tput sgr0)"

  8. egmontkob commented on Oct 6, 2019

    @egmontkob
    Author

    Re echo -e vs. printf: I know, using echo -e is a bad habit of mine, I know I should use printf. :)

    I disagree with tput, though (and echo vs printf doesn't really matter either). I'm not writing portable software here, I'm writing a reproducer test case for a bug in the terminal emulator.

    Using tput instead of raw escape sequence introduces a level of indirection, makes the behavior depend on $TERM as well as potentially the terminfo version where my intent is not to, and is IMO harder to read. The terminal emulator cares about numbers like 37 or 39, and not terminfo capabilities such as setaf.

    Also, by far not all escape sequences can be generated by tput, let alone deliberately broken ones, which some of my other bugreports are about.

    E.g. there's no terminfo capability I'm aware of that would generate \e[39m that my example uses. You mistakenly changed that to \e[37m, or, well, its tput equivalent, modifying the test case, which could be the reason for you not hitting the bug.

  9. DHowett-MSFT commented on Feb 21, 2020

    @DHowett-MSFT
    Contributor

    Lol- I just hit this myself, forgot we had a bug on it and re-investigated it.

    Apparently what I said months ago is still true. Weird how that works.

  10. ghost added
    In-PRThis issue has a related PR
    on Jun 15, 2020
  11. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Jul 1, 2020
  12. ghost removed
    In-PRThis issue has a related PR
    on Jul 1, 2020
  13. ghost added
    Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.
    on Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-VTVirtual Terminal sequence supportIssue-BugIt either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsPriority-2A description (P2)Product-ConptyFor console issues specifically related to conptyResolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions