Properly clear syntax highlighting when it is disabled

This commit is contained in:
Zachary Yedidia 2017-03-20 17:40:33 -04:00
parent 23152f0c50
commit 214adcf611
2 changed files with 16 additions and 0 deletions

View file

@ -467,3 +467,11 @@ func (b *Buffer) MoveLinesDown(start int, end int) {
Loc{0, end + 1},
)
}
// ClearMatches clears all of the syntax highlighting for this buffer
func (b *Buffer) ClearMatches() {
for i := range b.lines {
b.SetMatch(i, nil)
b.SetState(i, nil)
}
}

View file

@ -345,6 +345,14 @@ func SetLocalOption(option, value string, view *View) error {
buf.UpdateRules()
}
if option == "syntax" {
if !nativeValue.(bool) {
buf.ClearMatches()
} else {
buf.highlighter.Highlight(buf, 0)
}
}
return nil
}