Skip to content

Commit 521b63a

Browse files
committed
buffer/settings: On filetype change reload parsed local settings only
Additionally keep volatile settings as they have been set by the user.
1 parent 62c1c66 commit 521b63a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

internal/buffer/settings.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,23 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
2626
} else if option == "statusline" {
2727
screen.Redraw()
2828
} else if option == "filetype" {
29-
config.InitLocalSettings(b.Settings, b.Path)
29+
settings := config.ParsedSettings()
30+
settings["filetype"] = nativeValue
31+
config.InitLocalSettings(settings, b.Path)
32+
for k, v := range config.DefaultCommonSettings() {
33+
if k == "filetype" {
34+
continue
35+
}
36+
if _, ok := config.VolatileSettings[k]; ok {
37+
// filetype should not override volatile settings
38+
continue
39+
}
40+
if _, ok := settings[k]; ok {
41+
b.SetOptionNative(k, settings[k])
42+
} else {
43+
b.SetOptionNative(k, v)
44+
}
45+
}
3046
b.UpdateRules()
3147
} else if option == "fileformat" {
3248
switch b.Settings["fileformat"].(string) {

0 commit comments

Comments
 (0)