fix matching of empty patterns

This commit is contained in:
Manuel Barkhau 2020-12-06 22:53:23 +00:00
parent bce44fd240
commit dd575bede7
2 changed files with 56 additions and 6 deletions

View file

@ -55,7 +55,7 @@ PatternMatches = typ.Iterable[PatternMatch]
def _iter_for_pattern(lines: typ.List[str], pattern: Pattern) -> PatternMatches:
for lineno, line in enumerate(lines):
match = pattern.regexp.search(line)
if match:
if match and len(match.group(0)) > 0:
yield PatternMatch(lineno, line, pattern, match.span(), match.group(0))