From 352fd2be223bd1b12adb8abf3dc74651c89f9394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Sun, 21 Jul 2024 21:20:29 +0200 Subject: [PATCH] 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. --- internal/buffer/settings.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/buffer/settings.go b/internal/buffer/settings.go index aa011240..0af90ff8 100644 --- a/internal/buffer/settings.go +++ b/internal/buffer/settings.go @@ -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 } } }