mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-16 22:10:26 +00:00
Fix possible overflow error
This commit is contained in:
parent
d413562145
commit
9c5ab2afbd
2 changed files with 10 additions and 1 deletions
|
|
@ -188,6 +188,9 @@ func (c *CellView) Draw(buf *Buffer, top, height, left, width int) {
|
|||
}
|
||||
|
||||
for i := top; i < top+height; i++ {
|
||||
if i >= buf.NumLines {
|
||||
break
|
||||
}
|
||||
buf.SetMatch(i, nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,9 @@ func (h *Highlighter) highlightRegion(highlights LineMatch, start int, canMatchE
|
|||
|
||||
loc := findIndex(region.end, line, start == 0, canMatchEnd)
|
||||
if loc != nil {
|
||||
highlights[start+loc[1]-1] = region.group
|
||||
if !statesOnly {
|
||||
highlights[start+loc[1]-1] = region.group
|
||||
}
|
||||
if region.parent == nil {
|
||||
if !statesOnly {
|
||||
highlights[start+loc[1]] = 0
|
||||
|
|
@ -270,6 +272,10 @@ func (h *Highlighter) HighlightStates(input LineStates) {
|
|||
// This assumes that all the states are set correctly
|
||||
func (h *Highlighter) HighlightMatches(input LineStates, startline, endline int) {
|
||||
for i := startline; i < endline; i++ {
|
||||
if i >= input.LinesNum() {
|
||||
break
|
||||
}
|
||||
|
||||
line := []byte(input.Line(i))
|
||||
highlights := make(LineMatch)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue