auto-save.nvim icon indicating copy to clipboard operation
auto-save.nvim copied to clipboard

Fix issue of auto save and auto format conflicting.

Open wbjin opened this issue 1 year ago • 2 comments

When auto save and auto format is turned on together, undo and redo does not work as expected because of a circular relationship. Consider this situation:

  1. A change is made
  2. Auto save saves this change
  3. Auto format formats the changed buffer
  4. Auto save saves this formatting

When you try to undo, you will undo the formatting after which auto save will save this undoing. This creates a circular relationship between auto save and auto format causing issues.

Fix this issue by not auto saving on an undo.

wbjin avatar Apr 26 '24 18:04 wbjin

Nice find! Would you mind sharing that on https://github.com/okuuva/auto-save.nvim ? It's the more maintained fork (disclaimer, I'm one of the maintainers).

primeapple avatar May 03 '24 19:05 primeapple

Hey ! If you are using conform.nvim for formatting, there is a new format option called undojoin (see this PR. This option allows you to merge the formatting with the previous edition in the undo history, so that you don't have to care about formatting anymore with autosave.

Grolaf avatar Jul 16 '24 09:07 Grolaf