From 9fd42c368b9f2a7115c4948d9db586c501451e22 Mon Sep 17 00:00:00 2001 From: Henning Glawe <glaweh@debian.org> Date: Fri, 8 Jul 2016 23:20:17 +0200 Subject: [PATCH] switch ansi color only if group actually matched --- common/python/nomadcore/match_highlighter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/python/nomadcore/match_highlighter.py b/common/python/nomadcore/match_highlighter.py index 31d85e8..fdcf0b6 100644 --- a/common/python/nomadcore/match_highlighter.py +++ b/common/python/nomadcore/match_highlighter.py @@ -39,8 +39,9 @@ class MatchHighlighter(object): s,e=match.span(groupi) # logger.error("i:%d %3d %3d '%s'" % (groupi, s, e, # match.group(groupi))) - ansiSwitch.append([s,1,ANSI.FG_RED]) - ansiSwitch.append([e,0,ANSI.RESET_COLOR]) + if match.group(groupi) is not None: + ansiSwitch.append([s,1,ANSI.FG_RED]) + ansiSwitch.append([e,0,ANSI.RESET_COLOR]) # sort by position, then by event ansiSwitch=sorted(ansiSwitch, key=itemgetter(0,1)) if ansiSwitch[-1][0]>len(lineOrig): -- GitLab