Open bionicles opened 10 months ago
I think I hit the same bug
For a TLDR workaround, this fixed it for me, you have to create a Console to use a Theme, and in the theme set this key to this value:
"repr.ipv6": "default"
@bionicles thanks for the info! I can confirm that workaround fixes it for me too.
found https://github.com/Textualize/rich/issues/1259 and ridiculous regex is something i'm happy to work on, i may have found a fix!
Describe the bug
Double colon separators sometimes highlight in green due to false positive ipv6 ReprHighlighter regex match
Provide a minimal code example that demonstrates the issue if you can. If the issue is visual in nature, consider posting a screenshot.
remember
-s
flag to see the colors in pytestpytest tests/test_highlighter.py -s -k "double_colon"
Candidate add to test_highlighter.py:
Candidate Fix: rich/highlighter.py::ReprHighlighter (Around Line 90)
maybe that screws up ipv6 edge cases, however it un-screws-up the C code examples:
Here's the difference in test outcome:
Before:
After:
Then, of course, I found the answer was already in the closed issues:
TL;DR: It's an annoying visual bug which makes stuff look dumb, users can totally fix it themselves if they know they can re-theme a particular regex pattern in the ReprHighlighter, I personally didn't really know any of this stuff existed. Might be good to just remove the
:?
so people don't have to deal with that.Your test suite still passes with the new regex, but might be good to verify this doesn't cause issues
Alright, being a completionist and not wanting anyone else to need to context switch on this:
the new regex still works on the example long and short ipv6 from wikipedia https://en.wikipedia.org/wiki/IPv6
it just doesn't highlight the double colons in green, whatever, that's less annoying than a billion edge cases like this imho
Platform
Ubuntu 22.04.3 LTS? What terminal software are you using?
I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.
If you're using Rich in a terminal: