Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
48.84k stars 1.71k forks source link

Issues with link IDs and style caching #2949

Open rodrigogiraoserrao opened 1 year ago

rodrigogiraoserrao commented 1 year ago

This is an account of many small related issues (not necessarily bugs, per se) uncovered while working on https://github.com/Textualize/textual/issues/1587

Some examples https://github.com/Textualize/rich/blob/6d30ad0f30028210124c149811cbbe2b183711f9/rich/style.py#L192-L194 https://github.com/Textualize/rich/blob/6d30ad0f30028210124c149811cbbe2b183711f9/rich/style.py#L243 https://github.com/Textualize/rich/blob/6d30ad0f30028210124c149811cbbe2b183711f9/rich/style.py#L688

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?

@property
def link_id(self):
    return str(id(self)) if self.link or self.meta else ""
github-actions[bot] commented 1 year ago

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.

This is an automated reply, generated by FAQtory

willmcgugan commented 11 months ago

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.