(option string, nativeValue any, writeToFile bool)
| 631 | } |
| 632 | |
| 633 | func 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 | |
| 672 | func SetGlobalOption(option, value string, writeToFile bool) error { |
| 673 | if _, ok := config.GlobalSettings[option]; !ok { |
no test coverage detected