From d17b7f5110564463d94e2b91844c75a9747b46ab Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 12 Oct 2020 18:59:24 +0100 Subject: [PATCH] ignore blank matches --- rich/text.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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