MCPcopy Index your code
hub / github.com/micro-editor/micro / DoSetOptionNative

Method DoSetOptionNative

internal/buffer/settings.go:62–139  ·  view source on GitHub ↗
(option string, nativeValue any)

Source from the content-addressed store, hash-verified

60}
61
62func (b *Buffer) DoSetOptionNative(option string, nativeValue any) {
63 oldValue := b.Settings[option]
64 if reflect.DeepEqual(oldValue, nativeValue) {
65 return
66 }
67
68 b.Settings[option] = nativeValue
69
70 if option == "fastdirty" {
71 if !nativeValue.(bool) {
72 if b.Size() > LargeFileThreshold {
73 b.Settings["fastdirty"] = true
74 } else {
75 if !b.isModified {
76 b.calcHash(&b.origHash)
77 } else {
78 // prevent using an old stale origHash value
79 b.origHash = [md5.Size]byte{}
80 }
81 }
82 }
83 } else if option == "statusline" {
84 screen.Redraw()
85 } else if option == "filetype" {
86 b.ReloadSettings(false)
87 } else if option == "fileformat" {
88 switch b.Settings["fileformat"].(string) {
89 case "unix":
90 b.Endings = FFUnix
91 case "dos":
92 b.Endings = FFDos
93 }
94 b.setModified()
95 } else if option == "syntax" {
96 if !nativeValue.(bool) {
97 b.ClearMatches()
98 } else {
99 b.UpdateRules()
100 }
101 } else if option == "encoding" {
102 enc, err := htmlindex.Get(b.Settings["encoding"].(string))
103 if err != nil {
104 enc = unicode.UTF8
105 b.Settings["encoding"] = "utf-8"
106 }
107 b.encoding = enc
108 b.setModified()
109 } else if option == "readonly" && b.Type.Kind == BTDefault.Kind {
110 b.Type.Readonly = nativeValue.(bool)
111 } else if option == "hlsearch" {
112 for _, buf := range OpenBuffers {
113 if b.SharedBuffer == buf.SharedBuffer {
114 buf.HighlightSearch = nativeValue.(bool)
115 }
116 }
117 } else {
118 for _, pl := range config.Plugins {
119 if option == pl.Name {

Callers 3

ReloadSettingsMethod · 0.95
SetOptionNativeMethod · 0.95
SetGlobalOptionNativeFunction · 0.80

Calls 12

SizeMethod · 0.95
ReloadSettingsMethod · 0.95
ClearMatchesMethod · 0.95
UpdateRulesMethod · 0.95
doCallbacksMethod · 0.95
RedrawFunction · 0.92
TermMessageFunction · 0.92
calcHashMethod · 0.80
setModifiedMethod · 0.80
GetMethod · 0.80
LoadMethod · 0.80
CallMethod · 0.80

Tested by

no test coverage detected