You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an account of many small related issues (not necessarily bugs, per se) uncovered while working on Textualize/textual#1587
Hashing doesn't take into account the link ID, so styles that look the same but have different link IDs will clash.
Style._link_id is created inconsistently: the attribute _link_id is created in a couple of different places and is created inconsistently across those locations.
Style addition is cached in Style._add and the dunder method __add__ only refreshes the link (by using .copy on the result) if the result has a .link, but it doesn't check for .meta.
The method Text.render adds another layer of caching that bypasses the link refresh because of hashing clashes (maybe using the style indices instead of the styles themselves as cache keys fixes this).
I couldn't make much progress in solving these issues because I don't quite understand the semantics of the attribute .link_id. Is it supposed to be a different ID for any Style instance that contains a link or some meta data?
Then, why not use the object ID itself?
The _link_id is a unique id used when generating terminal links. It's sole purpose is to let the terminal know what to highlight when you hover over it.
This is an account of many small related issues (not necessarily bugs, per se) uncovered while working on Textualize/textual#1587
Hashing doesn't take into account the link ID, so styles that look the same but have different link IDs will clash.
Style._link_id
is created inconsistently: the attribute_link_id
is created in a couple of different places and is created inconsistently across those locations.Some examples
rich/rich/style.py
Lines 192 to 194 in 6d30ad0
rich/rich/style.py
Line 243 in 6d30ad0
rich/rich/style.py
Line 688 in 6d30ad0
Style addition is cached in
Style._add
and the dunder method__add__
only refreshes the link (by using.copy
on the result) if the result has a.link
, but it doesn't check for.meta
.The method
Text.render
adds another layer of caching that bypasses the link refresh because of hashing clashes (maybe using the style indices instead of the styles themselves as cache keys fixes this).I couldn't make much progress in solving these issues because I don't quite understand the semantics of the attribute
.link_id
. Is it supposed to be a different ID for anyStyle
instance that contains a link or some meta data?Then, why not use the object ID itself?
The text was updated successfully, but these errors were encountered: