rich icon indicating copy to clipboard operation
rich copied to clipboard

[BUG] `rich.traceback`: incorrect calculation of start and end of underlined text due to tab indentation

Open anamoyee opened this issue 7 months ago • 1 comments

  • [x] I've checked docs and closed issues for possible solutions.
  • [x] I can't find my issue in the FAQ.

Describe the bug

Rich incorrectly underlines the code during drawing of a traceback (it highlights the expression or statement that caused the exception) when the code is tab-indented, due to what i believe is miscalculation of the '\t' character as being 1-space indentation, but displaying it as 4-space indentation which causes the desync of the underline.

Image

Example of incorrectly drawn line (the line is 6 characters too much to the left - because 2 tabs = 2 * 3 missed spaces):

Image

Platform Windows Terminal on Windows 10

anamoyee avatar Jul 05 '25 17:07 anamoyee

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

Rich was created by Will McGugan. Consider sponsoring Will's work on Rich.

This is an automated reply, generated by FAQtory

github-actions[bot] avatar Jul 05 '25 17:07 github-actions[bot]