Fix small issue with regions
@@ -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 {
