From 5dd7f6fae55899897a2dbc322e614589a412e712 Mon Sep 17 00:00:00 2001 From: David Fokkema Date: Thu, 20 Aug 2026 17:29:05 +0200 Subject: [PATCH 1/2] Reuse link_id if link is split across lines --- src/textual/style.py | 5 ++++- tests/test_style_parse.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/textual/style.py b/src/textual/style.py index e14384d69b..6cceba68e8 100644 --- a/src/textual/style.py +++ b/src/textual/style.py @@ -492,7 +492,7 @@ def rich_style_with_offset(self, x: int, y: int) -> RichStyle: _meta, ) = _get_simple_attributes(self) color = None if foreground is None else background + foreground - return RichStyle( + rich_style = RichStyle( color=None if color is None else color.rich_color, bgcolor=None if background is None else background.rich_color, bold=bold, @@ -506,6 +506,9 @@ def rich_style_with_offset(self, x: int, y: int) -> RichStyle: link=link, meta={**self.meta, "offset": (x, y)}, ) + if link is not None or _meta is not None: + rich_style._link_id = f"L{id(self)}" + return rich_style @cached_property def without_color(self) -> Style: diff --git a/tests/test_style_parse.py b/tests/test_style_parse.py index 987d4852c0..6482d55442 100644 --- a/tests/test_style_parse.py +++ b/tests/test_style_parse.py @@ -54,3 +54,18 @@ def test_parse_style(markup: str, style: Style) -> None: print(parsed_style._meta) print(style._meta) assert parsed_style == style + + +@pytest.mark.parametrize( + "style", + [ + Style(link="https://textual.textualize.io"), + Style.from_meta({"@click": "app.bell"}), + ], +) +def test_rich_style_with_offset_reuses_link_id(style: Style) -> None: + + assert ( + style.rich_style_with_offset(0, 0)._link_id + == style.rich_style_with_offset(0, 1)._link_id + ) From 4ff1076a8c3c18b97fa458b324ea763adb893dc3 Mon Sep 17 00:00:00 2001 From: David Fokkema Date: Mon, 24 Aug 2026 17:30:24 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67652d343d..d1a5fba160 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Fixed + +- Fixed link highlighting when the link spans multiple lines https://github.com/Textualize/textual/pull/6703 + ## [8.2.8] - 2026-06-30 ### Fixed