diff --git a/pkg/highlight/highlighter.go b/pkg/highlight/highlighter.go index e78adca2ab..e7f04ce231 100644 --- a/pkg/highlight/highlighter.go +++ b/pkg/highlight/highlighter.go @@ -1,6 +1,7 @@ package highlight import ( + // "log" "regexp" "strings" @@ -94,12 +95,14 @@ func (h *Highlighter) highlightRange(fullHighlights []Group, start int, end int, if start <= end && end <= len(fullHighlights) { for i := start; i < end; i++ { fullHighlights[i] = group + // log.Println("fullHighlights[", i, "]:", group) } } } func (h *Highlighter) highlightPatterns(fullHighlights []Group, start int, lineNum int, line []byte, curRegion *region) { lineLen := util.CharacterCount(line) + // log.Println("highlightPatterns: lineNum:", lineNum, "start:", start, "line:", string(line)) if lineLen == 0 { return } @@ -123,6 +126,7 @@ func (h *Highlighter) highlightPatterns(fullHighlights []Group, start int, lineN func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNum int, line []byte, curRegion *region, regions []*region, nestedRegion bool) { lineLen := util.CharacterCount(line) + // log.Println("highlightRegions: lineNum:", lineNum, "start:", start, "line:", string(line)) if lineLen == 0 { return } @@ -141,10 +145,13 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu samePattern := false startLoop: for startIdx := 0; startIdx < len(startMatches); startIdx++ { + // log.Println("startIdx:", startIdx, "of", len(startMatches)) if startMatches[startIdx][0] < lineLen { for endIdx := 0; endIdx < len(endMatches); endIdx++ { + // log.Println("startIdx:", startIdx, "of", len(startMatches), "/ endIdx:", endIdx, "of", len(endMatches), "/ regionEnd:", regionEnd) if startMatches[startIdx][0] == endMatches[endIdx][0] { // start and end are the same (pattern) + // log.Println("start == end") samePattern = true if len(startMatches) == len(endMatches) { // special case in the moment both are the same @@ -166,6 +173,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu continue } // start and end at the current line + // log.Println("start < end") regionStart = startMatches[startIdx][0] regionEnd = endMatches[endIdx][1] h.highlightRange(fullHighlights, start+startMatches[startIdx][0], start+endMatches[endIdx][1], r.limitGroup) @@ -187,6 +195,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu continue } // start and end at the current line, but switched + // log.Println("end < start") h.highlightRange(fullHighlights, start, start+endMatches[endIdx][1], r.limitGroup) h.highlightRegions(fullHighlights, start, lineNum, util.SliceStart(line, endMatches[endIdx][0]), r, r.rules.regions, true) h.highlightPatterns(fullHighlights, start+endMatches[endIdx][1], lineNum, util.SliceStartEnd(line, endMatches[endIdx][1], startMatches[startIdx][0]), nil) @@ -200,6 +209,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu } if regionEnd <= startMatches[startIdx][0] { // start at the current, but end at the next line + // log.Println("start ...") regionStart = startMatches[startIdx][0] regionEnd = 0 h.highlightRange(fullHighlights, start+startMatches[startIdx][0], lineLen, r.limitGroup) @@ -215,6 +225,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu if (len(startMatches) == 0 && len(endMatches) > 0) || (samePattern && (len(startMatches) == len(endMatches))) { for _, endMatch := range endMatches { // end at the current, but start at the previous line + // log.Println("... end") h.highlightRange(fullHighlights, start, start+endMatch[1], r.limitGroup) h.highlightRegions(fullHighlights, start, lineNum, util.SliceStart(line, endMatch[0]), r, r.rules.regions, true) if curRegion != nil { @@ -235,6 +246,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu func (h *Highlighter) highlight(highlights LineMatch, start int, lineNum int, line []byte, curRegion *region) LineMatch { lineLen := util.CharacterCount(line) + // log.Println("highlight: lineNum:", lineNum, "start:", start, "line:", string(line)) if lineLen == 0 { return highlights }