Fix small issue with regions

This commit is contained in:
Zachary Yedidia
2017-03-16 13:15:12 -04:00
parent ea7f90713c
commit f637268fa7

View File

@@ -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 {