Skip to content

Commit 80d010c

Browse files
committed
highlighter: Fix limitGroup behavior of regions
This is just my interpretation of `limitGroup` as it might be intended a long time ago, but this interpretation could be wrong, since it is not really documented how it should be.
1 parent 535a090 commit 80d010c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

pkg/highlight/highlighter.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
169169
h.lastEnd = start + endMatch[1]
170170
update = true
171171
}
172-
h.highlightRange(fullHighlights, start+startMatch[0], start+endMatch[1], r.limitGroup)
172+
h.highlightRange(fullHighlights, start+startMatch[0], start+startMatch[1], r.limitGroup)
173+
h.highlightRange(fullHighlights, start+startMatch[1], start+endMatch[0], r.group)
174+
h.highlightRange(fullHighlights, start+endMatch[0], start+endMatch[1], r.limitGroup)
173175
h.highlightRegions(fullHighlights, start+startMatch[1], lineNum, util.SliceStartEnd(line, startMatch[1], endMatch[0]), r, r.rules.regions, true)
174176
if samePattern {
175177
startIdx += 1
@@ -191,7 +193,8 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
191193
// log.Println("end < start")
192194
h.lastStart = start
193195
h.lastEnd = start + endMatch[1]
194-
h.highlightRange(fullHighlights, start, start+endMatch[1], r.limitGroup)
196+
h.highlightRange(fullHighlights, start, start+endMatch[0], r.group)
197+
h.highlightRange(fullHighlights, start+endMatch[0], start+endMatch[1], r.limitGroup)
195198
h.highlightRegions(fullHighlights, start, lineNum, util.SliceStart(line, endMatch[0]), r, r.rules.regions, true)
196199
h.highlightPatterns(fullHighlights, start+endMatch[1], lineNum, util.SliceStartEnd(line, endMatch[1], startMatch[0]), nil)
197200
if curRegion != nil {
@@ -207,7 +210,8 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
207210
// log.Println("start ...")
208211
h.lastStart = start + startMatch[0]
209212
h.lastEnd = start + lineLen
210-
h.highlightRange(fullHighlights, start+startMatch[0], start+lineLen, r.limitGroup)
213+
h.highlightRange(fullHighlights, start+startMatch[0], start+startMatch[1], r.limitGroup)
214+
h.highlightRange(fullHighlights, start+startMatch[1], start+lineLen, r.group)
211215
h.highlightRegions(fullHighlights, start+startMatch[1], lineNum, util.SliceEnd(line, startMatch[1]), r, r.rules.regions, true)
212216
if h.lastStart == 0 || h.lastStart <= start+startMatch[0] {
213217
h.lastRegion = r
@@ -221,7 +225,8 @@ func (h *Highlighter) highlightRegions(fullHighlights []Group, start int, lineNu
221225
// log.Println("... end")
222226
h.lastStart = start
223227
h.lastEnd = start + endMatch[1]
224-
h.highlightRange(fullHighlights, start, start+endMatch[1], r.limitGroup)
228+
h.highlightRange(fullHighlights, start, start+endMatch[0], r.group)
229+
h.highlightRange(fullHighlights, start+endMatch[0], start+endMatch[1], r.limitGroup)
225230
h.highlightRegions(fullHighlights, start, lineNum, util.SliceStart(line, endMatch[0]), r, r.rules.regions, true)
226231
if curRegion != nil {
227232
h.lastRegion = r.parent

0 commit comments

Comments
 (0)