Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
addresses issues brought up in #1112 (currently closed)
Problem
Updating the time stamp can cause issues with undo-ing things. This is particularly bad when an autosave plugin is used b/c the user will make a change > autosave > timestamp update > autosave > undo (undoes timestamp update) > autosave > timestamp update > loop. The scenario's described assume there is an autosave plugin saving on text change/insert leave.
Making it impossible to undo changes in the norg file with autosave (while the
updated:
field is present in the metadata).Proposed Solution
This PR makes two changes that make it possible to bind keys to mitigate this issue:
["core.esupports.metagen"].config.undojoin_updates = true
- When true, we call:undojoin
just before updating theupdated:
field in the metadata. With this set to true you can make a change, write the file and pressu
to undo your change and the timestamp update. But, you will still get another time stamp update after the undo. Making multiple undos in a row impossible b/c of branches. Enter: the second addition..require("neorg.modules.core.esupports.metagen.module").public.skip_next_update()
- a function which will disable exactly one metadata 'updated at' update. This function can prevent the issue above, and makes it possible to remap theu
and<c-r>
keys so that they behave mostly normally in a norg doc with autosave.This solution is maybe not the most elegant. I'm open to feedback on how to make it better, I threw this together quickly and without much thought after I realized that it would mostly work.
I'd like to test drive this for a few more days as well before it potentially gets merged.
Example Usage