MCPcopy
hub / github.com/micro-editor/micro / ReHighlightLine

Method ReHighlightLine

pkg/highlight/highlighter.go:386–408  ·  view source on GitHub ↗

ReHighlightLine will rehighlight the state and match for a single line

(input LineStates, lineN int)

Source from the content-addressed store, hash-verified

384
385// ReHighlightLine will rehighlight the state and match for a single line
386func (h *Highlighter) ReHighlightLine(input LineStates, lineN int) {
387 input.Lock()
388 defer input.Unlock()
389
390 line := input.LineBytes(lineN)
391 highlights := make(LineMatch)
392
393 h.lastRegion = nil
394 if lineN > 0 {
395 h.lastRegion = input.State(lineN - 1)
396 }
397
398 var match LineMatch
399 if lineN == 0 || h.lastRegion == nil {
400 match = h.highlightEmptyRegion(highlights, 0, true, lineN, line, false)
401 } else {
402 match = h.highlightRegion(highlights, 0, true, lineN, line, h.lastRegion, false)
403 }
404 curState := h.lastRegion
405
406 input.SetMatch(lineN, match)
407 input.SetState(lineN, curState)
408}

Callers

nothing calls this directly

Calls 8

highlightEmptyRegionMethod · 0.95
highlightRegionMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65
LineBytesMethod · 0.65
StateMethod · 0.65
SetMatchMethod · 0.65
SetStateMethod · 0.65

Tested by

no test coverage detected