Skip to content

Commit 7f6733a

Browse files
committed
highlighter: Add disabled debug logs for faster analysis
1 parent 94710f0 commit 7f6733a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pkg/highlight/highlighter.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package highlight
22

33
import (
4+
// "log"
45
"regexp"
56
"strings"
67

@@ -94,12 +95,14 @@ func (h *Highlighter) highlightRange(fullHighlights []Group, start int, end int,
9495
if start <= end && end <= len(fullHighlights) {
9596
for i := start; i < end; i++ {
9697
fullHighlights[i] = group
98+
// log.Println("fullHighlights[", i, "]:", group)
9799
}
98100
}
99101
}
100102

101103
func (h *Highlighter) highlightPatterns(fullHighlights []Group, start int, lineNum int, line []byte, curRegion *region) {
102104
lineLen := util.CharacterCount(line)
105+
// log.Println("highlightPatterns: lineNum:", lineNum, "start:", start, "line:", string(line))
103106
if lineLen == 0 {
104107
return
105108
}
@@ -123,6 +126,7 @@ func (h *Highlighter) highlightPatterns(fullHighlights []Group, start int, lineN
123126

124127
func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNum int, line []byte, curRegion *region, regions []*region, nestedRegion bool) {
125128
lineLen := util.CharacterCount(line)
129+
// log.Println("highlightRegions: lineNum:", lineNum, "start:", start, "line:", string(line))
126130
if lineLen == 0 {
127131
return
128132
}
@@ -141,10 +145,13 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
141145
samePattern := false
142146
startLoop:
143147
for startIdx := 0; startIdx < len(startMatches); startIdx++ {
148+
// log.Println("startIdx:", startIdx, "of", len(startMatches))
144149
if startMatches[startIdx][0] < lineLen {
145150
for endIdx := 0; endIdx < len(endMatches); endIdx++ {
151+
// log.Println("startIdx:", startIdx, "of", len(startMatches), "/ endIdx:", endIdx, "of", len(endMatches), "/ regionEnd:", regionEnd)
146152
if startMatches[startIdx][0] == endMatches[endIdx][0] {
147153
// start and end are the same (pattern)
154+
// log.Println("start == end")
148155
samePattern = true
149156
if len(startMatches) == len(endMatches) {
150157
// special case in the moment both are the same
@@ -166,6 +173,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
166173
continue
167174
}
168175
// start and end at the current line
176+
// log.Println("start < end")
169177
regionStart = startMatches[startIdx][0]
170178
regionEnd = endMatches[endIdx][1]
171179
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
187195
continue
188196
}
189197
// start and end at the current line, but switched
198+
// log.Println("end < start")
190199
h.highlightRange(fullHighlights, start, start+endMatches[endIdx][1], r.limitGroup)
191200
h.highlightRegions(fullHighlights, start, lineNum, util.SliceStart(line, endMatches[endIdx][0]), r, r.rules.regions, true)
192201
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
200209
}
201210
if regionEnd <= startMatches[startIdx][0] {
202211
// start at the current, but end at the next line
212+
// log.Println("start ...")
203213
regionStart = startMatches[startIdx][0]
204214
regionEnd = 0
205215
h.highlightRange(fullHighlights, start+startMatches[startIdx][0], lineLen, r.limitGroup)
@@ -215,6 +225,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
215225
if (len(startMatches) == 0 && len(endMatches) > 0) || (samePattern && (len(startMatches) == len(endMatches))) {
216226
for _, endMatch := range endMatches {
217227
// end at the current, but start at the previous line
228+
// log.Println("... end")
218229
h.highlightRange(fullHighlights, start, start+endMatch[1], r.limitGroup)
219230
h.highlightRegions(fullHighlights, start, lineNum, util.SliceStart(line, endMatch[0]), r, r.rules.regions, true)
220231
if curRegion != nil {
@@ -235,6 +246,7 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
235246

236247
func (h *Highlighter) highlight(highlights LineMatch, start int, lineNum int, line []byte, curRegion *region) LineMatch {
237248
lineLen := util.CharacterCount(line)
249+
// log.Println("highlight: lineNum:", lineNum, "start:", start, "line:", string(line))
238250
if lineLen == 0 {
239251
return highlights
240252
}

0 commit comments

Comments
 (0)