Skip to content

Commit 93efc9e

Browse files
committed
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 zyedidia#3343 which makes `set` do nothing if the option value doesn't change.
1 parent 352fd2b commit 93efc9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/buffer/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
1212

1313
if option == "fastdirty" {
1414
if !nativeValue.(bool) {
15-
if !b.Modified() {
15+
if !b.isModified {
1616
e := calcHash(b, &b.origHash)
1717
if e == ErrFileTooLarge {
1818
b.Settings["fastdirty"] = true

0 commit comments

Comments
 (0)