diff --git a/rich/text.py b/rich/text.py index 71eb82bb..8e3d5380 100644 --- a/rich/text.py +++ b/rich/text.py @@ -413,13 +413,13 @@ class Text(JupyterMixin): if style: start, end = get_span() match_style = style(plain[start:end]) if callable(style) else style - if match_style is not None and end - start: + if match_style is not None and end > start: append_span(_Span(start, end, match_style)) count += 1 for name in match.groupdict().keys(): start, end = get_span(name) - if start != -1 and end - start: + if start != -1 and end > start: append_span(_Span(start, end, f"{style_prefix}{name}")) return count