Skip to content

Fix issue of auto save and auto format conflicting.#87

Open
wbjin wants to merge 2 commits into
pocco81:mainfrom
wbjin:main
Open

Fix issue of auto save and auto format conflicting.#87
wbjin wants to merge 2 commits into
pocco81:mainfrom
wbjin:main

Conversation

@wbjin
Copy link
Copy Markdown

@wbjin wbjin commented Apr 26, 2024

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.

@primeapple
Copy link
Copy Markdown

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).

@Grolaf
Copy link
Copy Markdown

Grolaf commented Jul 16, 2024

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.

vuthanhtung2412 added a commit to vuthanhtung2412/nvim-config that referenced this pull request Nov 11, 2024
auto format and auto save create a circular loop that mess up undo tree
: pocco81/auto-save.nvim#87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants