ziglang / zig-mode

Zig mode for Emacs
GNU General Public License v3.0
157 stars 54 forks source link

zig-format-on-save: File digest doesn't match, so undo history will be discarded #72

Closed Inc0n closed 1 year ago

Inc0n commented 1 year ago

Sometimes, the following would happen on save and result in losses of undo-history.

It is determined that zig-format-on-save is the culprit, and setting it to nil can be a workaround.

buffer-undo-list is not empty. Do you want to recover now? (y or n) y File digest doesn’t match, so undo history will be discarded.

joachimschmidt557 commented 1 year ago

This issue would be fixed by moving formatting to reformatter (https://github.com/ziglang/zig-mode/issues/39, https://github.com/ziglang/zig-mode/pull/51, https://github.com/ziglang/zig-mode/discussions/75).

When using reformatter, formatting itself is an operation that can be undo-ed, in the status quo we run zig fmt on the file and revert the buffer, which causes all sorts of issues.