buffer/settings: On fastdirty off set to on in case of "large file"

This behavior is then aligned to the actual documentation of `fastdirty`.
Additionally set the origHash to zero in case the buffer was already modified.
This commit is contained in:
Jöran Karl
2024-07-21 21:20:29 +02:00
committed by Dmytro Maluka
parent c0f6b65ed6
commit 352fd2be22

View File

@@ -1,6 +1,8 @@
package buffer
import (
"crypto/md5"
"github.com/zyedidia/micro/v2/internal/config"
"github.com/zyedidia/micro/v2/internal/screen"
)
@@ -13,7 +15,12 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
if !b.Modified() {
e := calcHash(b, &b.origHash)
if e == ErrFileTooLarge {
b.Settings["fastdirty"] = false
b.Settings["fastdirty"] = true
}
} else {
b.origHash = [md5.Size]byte{}
if b.Size() > LargeFileThreshold {
b.Settings["fastdirty"] = true
}
}
}