Properly clear syntax highlighting when it is disabled
This commit is contained in:
parent
23152f0c50
commit
214adcf611
2 changed files with 16 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue