From f637268fa7d6aa77c29a9869fb2249f3b0fd6b7f Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 16 Mar 2017 13:15:12 -0400 Subject: [PATCH] Fix small issue with regions --- cmd/micro/highlight/highlighter.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/micro/highlight/highlighter.go b/cmd/micro/highlight/highlighter.go index a60aa196..20c3466a 100644 --- a/cmd/micro/highlight/highlighter.go +++ b/cmd/micro/highlight/highlighter.go @@ -73,14 +73,6 @@ func FindAllIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd b func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, line []byte, region *Region) LineMatch { highlights := make(LineMatch) - if len(line) == 0 { - if canMatchEnd { - h.lastRegion = region - } - - return highlights - } - loc := FindIndex(region.end, line, start == 0, canMatchEnd) if loc != nil { if region.parent == nil { @@ -95,6 +87,14 @@ func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, h.highlightRegion(start+loc[1], canMatchEnd, lineNum, line[loc[1]:], region.parent))) } + if len(line) == 0 { + if canMatchEnd { + h.lastRegion = region + } + + return highlights + } + firstLoc := []int{len(line), 0} var firstRegion *Region for _, r := range region.rules.regions {