Fix possible overflow error

This commit is contained in:
Zachary Yedidia
2017-03-25 17:31:46 -04:00
parent d413562145
commit 9c5ab2afbd
2 changed files with 10 additions and 1 deletions

View File

@@ -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)
}
}

View File

@@ -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)