From 93efc9eabe23adec1a33049470dced484f0d1630 Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sun, 18 Aug 2024 14:40:31 +0200 Subject: [PATCH] buffer/settings: Don't use Modified() before we updated origHash When we have already enabled `fastdirty` but have not updated origHash yet, we shouldn't use Modified() since it depends on origHash which is still outdated, and thus returns wrong values. This fixes the following issue: enable `fastdirty`, modify the buffer, save the buffer and disable `fastdirty` -> micro wrongly reports the buffer as modified (whereas it has just been saved). Note that this fix, though, also causes a regression: e.g. if we run `set fastdirty false` while fastdirty is already disabled, micro may unexpectedly report a non-modified buffer as modified (in the case if isModified is true but the buffer it actually not modified, since its md5 sum matches and fastdirty is disabled), since this fix assumes that since we are disabling fastdirty, it has been enabled. This shall be fixed by PR #3343 which makes `set` do nothing if the option value doesn't change. --- internal/buffer/settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/buffer/settings.go b/internal/buffer/settings.go index 0af90ff8..e934da2f 100644 --- a/internal/buffer/settings.go +++ b/internal/buffer/settings.go @@ -12,7 +12,7 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error { if option == "fastdirty" { if !nativeValue.(bool) { - if !b.Modified() { + if !b.isModified { e := calcHash(b, &b.origHash) if e == ErrFileTooLarge { b.Settings["fastdirty"] = true