diff --git a/cmd/micro/buffer.go b/cmd/micro/buffer.go index 1d054446..4ad2cf8a 100644 --- a/cmd/micro/buffer.go +++ b/cmd/micro/buffer.go @@ -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) + } +} diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index 902067e7..191854be 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -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 }