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

Function SetGlobalOptionNative

internal/action/command.go:633–670  ·  view source on GitHub ↗
(option string, nativeValue any, writeToFile bool)

Source from the content-addressed store, hash-verified

631}
632
633func SetGlobalOptionNative(option string, nativeValue any, writeToFile bool) error {
634 if err := config.OptionIsValid(option, nativeValue); err != nil {
635 return err
636 }
637
638 // check for local option first...
639 for _, s := range config.LocalSettings {
640 if s == option {
641 return MainTab().CurPane().Buf.SetOptionNative(option, nativeValue)
642 }
643 }
644
645 // ...if it's not local continue with the globals...
646 if err := doSetGlobalOptionNative(option, nativeValue); err != nil {
647 return err
648 }
649
650 // ...at last check the buffer locals
651 for _, b := range buffer.OpenBuffers {
652 b.DoSetOptionNative(option, nativeValue)
653 delete(b.LocalSettings, option)
654 }
655
656 if !writeToFile {
657 return nil
658 }
659
660 err := config.WriteSettings(filepath.Join(config.ConfigDir, "settings.json"))
661 if err != nil {
662 if errors.Is(err, util.ErrOverwrite) {
663 screen.TermMessage(err)
664 err = errors.Unwrap(err)
665 }
666 return err
667 }
668
669 return nil
670}
671
672func SetGlobalOption(option, value string, writeToFile bool) error {
673 if _, ok := config.GlobalSettings[option]; !ok {

Callers 4

SetGlobalOptionFunction · 0.85
ResetCmdMethod · 0.85
toggleOptionMethod · 0.85

Calls 11

OptionIsValidFunction · 0.92
WriteSettingsFunction · 0.92
TermMessageFunction · 0.92
MainTabFunction · 0.85
doSetGlobalOptionNativeFunction · 0.85
SetOptionNativeMethod · 0.80
CurPaneMethod · 0.80
DoSetOptionNativeMethod · 0.80
JoinMethod · 0.80
IsMethod · 0.80
UnwrapMethod · 0.80

Tested by

no test coverage detected