-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix spurious backups of unmodified files #3822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+141
−131
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4ade5cd
Make calcHash() a method of SharedBuffer
dmaluka f938f62
Make isModified reflect actual modified/unmodified state of buffer
dmaluka e84d44d
Move backup & save related stuff from Buffer to SharedBuffer
dmaluka 2c010af
Fix races between removing backups and creating periodic backups
dmaluka 7aa495f
Remove backup when buffer becomes unmodified
dmaluka e127f08
On panic, backup modified buffers only
dmaluka 04b878b
Ignore the `backup` option when removing backup
dmaluka a862c97
Unify backup write logic
dmaluka 0a9fa4f
Always use temporary file when writing backup
dmaluka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this doesn't help for large file, right? Because
b.isModifiedis alwaystruedue tofastdirtybeing forced totrue.At least we know when the
UndoStackis empty. 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that's a separate issue, not exactly related to backups, right? It's annoying that the buffer status remains "modified" until the user saves the buffer, but that is something the user is aware of (the statusline shows that the buffer is modified, and micro asks to save the file when the user closes it), so at least it is not unexpected that micro does not remove the backup until the user saves the buffer, right?
...Though while we're at this topic, I agree we should improve that by simply checking if the undo stack is empty (or more precisely, if it has the same size as the last time when the buffer was saved). Unfortunately, as I noted elsewhere, it is not that easy: first we need to fix bypassing the undo stack in
Retab()andMoveLinesUp()(at least).And last time I tried to fix that in
MoveLinesUp(), I failed to figure out how to do that correctly (i.e. in such a way that wouldn't breakMoveLinesUp()itself, when the cursor is at the last line).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least not more than 7aa495f. 😉
Agree. Should be handled independent of this PR then. 👍