Skip to content
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

Fix: Undo and redo correctly updates editor modified status #244

Merged

Conversation

joshuamegnauth54
Copy link
Contributor

Related to two issues on cosmic-edit:

  • #116
  • #128 - I will work on 128 on a separate PR, but the code here is related to it.

I implemented a fix for two TODOs related to the issues above. Prior to this patch, undoing and redoing changes don't unset the editor's changed flag. The editor seems to be always marked as changed unless manually set to unchanged.

I fixed this issue by adding a save point to the editor which sets the current change to the last saved state. Undoing or redoing past this change correctly sets the editor as modified. Undoing or redoing TO the save point sets the editor as unmodified.

I wrote several unit tests to validate the behavior above - they're likely clearer than my explanation above. 😹

joshuamegnauth54 and others added 6 commits March 23, 2024 22:50
I added an index that represents the last saved change.

Editors are considered to be unsaved or modified if the current change
is different from the save index. In other words, if the last saved
change is `5`, undoing or redoing past that change should indicate that
the editor has been modified.

This is needed to fix two bugs in COSMIC Edit:
* pop-os/cosmic-edit#116
* pop-os/cosmic-edit#128
I'll most likely simplify the API as end users don't have a way to
cleanly use `Pivot::Exact` without access to the internal command
buffer.
A unit test for an edge case currently fails but normal usage works.
@jackpot51 jackpot51 merged commit ff5501d into pop-os:main Mar 25, 2024
1 of 2 checks passed
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.

2 participants