buffer/settings: On filetype change reload parsed local settings only

Additionally keep volatile settings as they have been set by the user.
This commit is contained in:
Jöran Karl 2024-06-17 17:34:38 +02:00
parent 62c1c667b8
commit 521b63a28c

View File

@ -26,7 +26,23 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
} else if option == "statusline" { } else if option == "statusline" {
screen.Redraw() screen.Redraw()
} else if option == "filetype" { } else if option == "filetype" {
config.InitLocalSettings(b.Settings, b.Path) settings := config.ParsedSettings()
settings["filetype"] = nativeValue
config.InitLocalSettings(settings, b.Path)
for k, v := range config.DefaultCommonSettings() {
if k == "filetype" {
continue
}
if _, ok := config.VolatileSettings[k]; ok {
// filetype should not override volatile settings
continue
}
if _, ok := settings[k]; ok {
b.SetOptionNative(k, settings[k])
} else {
b.SetOptionNative(k, v)
}
}
b.UpdateRules() b.UpdateRules()
} else if option == "fileformat" { } else if option == "fileformat" {
switch b.Settings["fileformat"].(string) { switch b.Settings["fileformat"].(string) {