Skip to content

Wrong calculation of width of text including ANSI color sequences #4065

@rhysd

Description

@rhysd

Describe the bug

  • gh version: 1.13.1
  • OS: macOS 10.15

When showing some outputs with table writer, width of some cell is wrong. For example:

スクリーンショット 2021-07-31 2 53 23

In this example, the start position of 'about 3 hours ago' at issue #19 is wrong. This is because issue labels are colorized with ANSI color sequences like \x1b[38;2;215;58;74mbug\x1b[0m and the logic to calculate display width of text does not consider the sequences.

Steps to reproduce the behavior

  1. Checkout some repository which has two open issues. And those issues should have different number of labels.
  2. Run gh issue list
  3. See output and confirm the start position of column of issue date is wrong

Expected vs actual behavior

  • Expected: Width of display text must consider ANSI escape sequences since such sequences are actually not rendered on terminal
  • Actual: ANSI escape sequences are included in display text. For example, width of (\x1b[38;2;162;238;239menhancement\x1b[0m) is calculated as 34.

Logs

U'w') { gh issue list

Showing 2 of 2 open issues in rhysd/actionlint

#19  Feature Request: checking for Untrusted input                  (enhancement)                          about 3 hours ago
#18  "is not defined in object type" error with marketplace action  (bug, false-positive)  about 53 minutes ago

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions