MCPcopy
hub / github.com/micro-editor/micro / ReloadSettings

Method ReloadSettings

internal/buffer/settings.go:15–60  ·  view source on GitHub ↗
(reloadFiletype bool)

Source from the content-addressed store, hash-verified

13)
14
15func (b *Buffer) ReloadSettings(reloadFiletype bool) {
16 settings := config.ParsedSettings()
17 config.UpdatePathGlobLocals(settings, b.AbsPath)
18
19 oldFiletype := b.Settings["filetype"].(string)
20
21 _, local := b.LocalSettings["filetype"]
22 _, volatile := config.VolatileSettings["filetype"]
23 if reloadFiletype && !local && !volatile {
24 // need to update filetype before updating other settings based on it
25 b.Settings["filetype"] = "unknown"
26 if v, ok := settings["filetype"]; ok {
27 b.Settings["filetype"] = v
28 }
29 }
30
31 // update syntax rules, which will also update filetype if needed
32 b.UpdateRules()
33
34 curFiletype := b.Settings["filetype"].(string)
35 if oldFiletype != curFiletype {
36 b.doCallbacks("filetype", oldFiletype, curFiletype)
37 }
38
39 config.UpdateFileTypeLocals(settings, curFiletype)
40
41 for k, v := range config.DefaultCommonSettings() {
42 if k == "filetype" {
43 // prevent recursion
44 continue
45 }
46 if _, ok := config.VolatileSettings[k]; ok {
47 // reload should not override volatile settings
48 continue
49 }
50 if _, ok := b.LocalSettings[k]; ok {
51 // reload should not override local settings
52 continue
53 }
54 if _, ok := settings[k]; ok {
55 b.DoSetOptionNative(k, settings[k])
56 } else {
57 b.DoSetOptionNative(k, v)
58 }
59 }
60}
61
62func (b *Buffer) DoSetOptionNative(option string, nativeValue any) {
63 oldValue := b.Settings[option]

Callers 3

saveToFileMethod · 0.95
DoSetOptionNativeMethod · 0.95
reloadRuntimeFunction · 0.80

Calls 7

UpdateRulesMethod · 0.95
doCallbacksMethod · 0.95
DoSetOptionNativeMethod · 0.95
ParsedSettingsFunction · 0.92
UpdatePathGlobLocalsFunction · 0.92
UpdateFileTypeLocalsFunction · 0.92
DefaultCommonSettingsFunction · 0.92

Tested by

no test coverage detected