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
Styling part of a link breaks it. This is best illustrated with a code example:
importrich.consoleimportrich.textconsole=rich.console.Console()
text=rich.text.Text(
'This is a link',
style=console.get_style('green').update_link('https://example.com'),
)
text.highlight_words(['link'], style='bold')
console.print(text)
now if you hover over "This is a link isn't it", you'll see that link and This is a isn't it are considered separate links.
Running FORCE_COLOR=1 python linkbug.py | xxd confirms that the differently-highlighted text parts get different link IDs (but the prefix and the suffix get the same one).
Platform
Click to expand
Ubuntu 24.04, with GNOME Terminal 3.52.0 using VTE 0.76.0 +BIDI +GNUTLS +ICU +SYSTEMD.
Removing the combined_style.copy() done in Style.__add__ fixes this bug for me. git blame is not very informative about why that .copy() was added there.
I'm seeing no new unit test failures in tox -e py312 if I remove the .copy(). (I'm seeing 6 failures in test_size_can_fall_back_to_std_descriptors, but they fail for me on git master with no local modifications as well.)
I now see that removing the .copy() in Style.__add__ makes unrelated links that point to the same URL and have the same style attributes get the same link ID:
importrich.consoleimportrich.textconsole=rich.console.Console()
text=rich.text.Text(
'This is a link',
style=console.get_style('green').update_link('https://example.com'),
)
text.highlight_words(['link'], style='bold')
console.print(text)
text=rich.text.Text(
'This is another link',
style=console.get_style('green').update_link('https://example.com'),
)
console.print(text)
Describe the bug
Styling part of a link breaks it. This is best illustrated with a code example:
now if you hover over "This is a link isn't it", you'll see that
link
andThis is a isn't it
are considered separate links.Running
FORCE_COLOR=1 python linkbug.py | xxd
confirms that the differently-highlighted text parts get different link IDs (but the prefix and the suffix get the same one).Platform
Click to expand
Ubuntu 24.04, with GNOME Terminal 3.52.0 using VTE 0.76.0 +BIDI +GNUTLS +ICU +SYSTEMD.
The text was updated successfully, but these errors were encountered: