refactor: use a more modern writing style to simplify code (#3834)

Signed-off-by: deepdring <deepdrink@icloud.com>
This commit is contained in:
deepdring
2025-08-26 08:00:51 +08:00
committed by GitHub
parent 094b02da4c
commit b8057f28c6
24 changed files with 98 additions and 100 deletions

View File

@@ -82,7 +82,7 @@ type SharedBuffer struct {
toStdout bool
// Settings customized by the user
Settings map[string]interface{}
Settings map[string]any
// LocalSettings customized by the user for this buffer only
LocalSettings map[string]bool
@@ -236,7 +236,7 @@ type Buffer struct {
// is properly updated when needed. This is a workaround for the fact that
// the buffer module cannot directly call the display's API (it would mean
// a circular dependency between packages).
OptionCallback func(option string, nativeValue interface{})
OptionCallback func(option string, nativeValue any)
// The display module registers its own GetVisualX function for getting
// the correct visual x location of a cursor when softwrap is used.

View File

@@ -84,7 +84,7 @@ func (b *Buffer) ClearAllMessages() {
}
type Messager interface {
Message(msg ...interface{})
Message(msg ...any)
}
var prompt Messager

View File

@@ -59,7 +59,7 @@ func (b *Buffer) ReloadSettings(reloadFiletype bool) {
}
}
func (b *Buffer) DoSetOptionNative(option string, nativeValue interface{}) {
func (b *Buffer) DoSetOptionNative(option string, nativeValue any) {
oldValue := b.Settings[option]
if reflect.DeepEqual(oldValue, nativeValue) {
return
@@ -138,7 +138,7 @@ func (b *Buffer) DoSetOptionNative(option string, nativeValue interface{}) {
b.doCallbacks(option, oldValue, nativeValue)
}
func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
func (b *Buffer) SetOptionNative(option string, nativeValue any) error {
if err := config.OptionIsValid(option, nativeValue); err != nil {
return err
}
@@ -163,7 +163,7 @@ func (b *Buffer) SetOption(option, value string) error {
return b.SetOptionNative(option, nativeValue)
}
func (b *Buffer) doCallbacks(option string, oldValue interface{}, newValue interface{}) {
func (b *Buffer) doCallbacks(option string, oldValue any, newValue any) {
if b.OptionCallback != nil {
b.OptionCallback(option, newValue)
}