Repository navigation
Conversation
When readOnly.toggle() calls Saver.save() and it throws (now that #3030 makes save failures propagate), the editor was left flagged as read-only while blocks remained editable. This commit wraps the save call in try-catch and restores the previous read-only state on error. Adds Cypress test covering: a tool whose save throws, so readOnly.toggle() rejects; afterwards the editor isn't read-only and editor.save() works once the failure is gone. Co-authored-by: Peter <neSpecc@users.noreply.github.com>
Extract the loop that calls toggleReadOnly on all Editor modules into a private method to eliminate duplication between the normal toggle path and the error recovery path. Co-authored-by: Peter <neSpecc@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR supersedes #3033 (opened by @Sion612) and completes the outstanding review items.
Changes
Original work by @Sion612:
Saver.save()to rethrow errors after logging, so save failures propagate to callers (Silent Data Loss & Broken Error Contract in Saver.save() #3030)Additional fixes:
readOnly.toggle()to restore editor to consistent state if save fails: when the save throws, the editor is restored to its previous read-only state (wraps save in try-catch, restores state on error)readOnly.toggle(), the editor is not in read-only mode andeditor.save()works once the failure is goneWhy this PR supersedes #3033
The original PR branch couldn't be updated because push access to the fork
Sion612/editor.jswas not available through the maintainer edit permissions. This PR preserves the original author's commit and authorship, adds the requested fixes on top, and rebases everything onto the currentnextbranch.Testing
All lints and relevant Cypress specs pass:
Fixes #3030