Fix end line number in HighlightMatches (#1662)

There is a bit of mess in the usage of HighlightMatches: in some places
we assume that it updates lines from startline to endline inclusive,
in other places we assume it's non-inclusive.
This fix makes it always inclusive.

In particular, it fixes a bug: when we open a file which has no
newline at the end, the last line isn't highlighted.
This commit is contained in:
dmaluka
2020-05-17 22:05:34 +02:00
committed by GitHub
parent 299af4a3db
commit a150eef6f9
2 changed files with 5 additions and 5 deletions

View File

@@ -152,14 +152,14 @@ func (b *SharedBuffer) MarkModified(start, end int) {
return
}
start = util.Clamp(start, 0, len(b.lines))
end = util.Clamp(end, 0, len(b.lines))
start = util.Clamp(start, 0, len(b.lines)-1)
end = util.Clamp(end, 0, len(b.lines)-1)
l := -1
for i := start; i <= end; i++ {
l = util.Max(b.Highlighter.ReHighlightStates(b, i), l)
}
b.Highlighter.HighlightMatches(b, start, l+1)
b.Highlighter.HighlightMatches(b, start, l)
}
// DisableReload disables future reloads of this sharedbuffer