(option string, nativeValue any)
| 60 | } |
| 61 | |
| 62 | func (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 { |
no test coverage detected