mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-09-05 16:37:20 -04:00
Fix bug with regions
This commit is contained in:
+8
-8
@@ -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 {
|
func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, line []byte, region *Region) LineMatch {
|
||||||
highlights := make(LineMatch)
|
highlights := make(LineMatch)
|
||||||
|
|
||||||
if len(line) == 0 {
|
|
||||||
if canMatchEnd {
|
|
||||||
h.lastRegion = region
|
|
||||||
}
|
|
||||||
|
|
||||||
return highlights
|
|
||||||
}
|
|
||||||
|
|
||||||
loc := FindIndex(region.end, line, start == 0, canMatchEnd)
|
loc := FindIndex(region.end, line, start == 0, canMatchEnd)
|
||||||
if loc != nil {
|
if loc != nil {
|
||||||
if region.parent == 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)))
|
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}
|
firstLoc := []int{len(line), 0}
|
||||||
var firstRegion *Region
|
var firstRegion *Region
|
||||||
for _, r := range region.rules.regions {
|
for _, r := range region.rules.regions {
|
||||||
|
|||||||
Reference in New Issue
Block a user