From 738fecd4007afa97818479e86b066c0d18f64c0e Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Fri, 6 Nov 2026 03:42:00 -0500 Subject: [PATCH] Content answers whether it draws like another, not only whether its text matches Written by claude-b-ui. Content.__eq__ compares plain text only, for sorting, so a widget that skipped an update when the content was equal dropped every change that only moved spans: a goal mention becoming a link once its peer was observed, and every theme recolour. draws_like compares the text and the styled spans. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XbFMSqJMarXn2ZE8iAL7Sd --- src/textual/content.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/textual/content.py b/src/textual/content.py index 1c8ac47d28..3d3c370b78 100644 --- a/src/textual/content.py +++ b/src/textual/content.py @@ -523,6 +523,13 @@ def add_spans(self, spans: Sequence[Span]) -> Content: ) return self + def draws_like(self, other: Content) -> bool: + """Whether both draw the same: the same text with the same styled spans. + + Equality compares text only, for sorting; a changed style or link is a change on screen. + """ + return self.plain == other.plain and list(self._spans) == list(other._spans) + def __eq__(self, other: object) -> bool: """Compares text only, so that markup doesn't effect sorting.""" if isinstance(other, str):