Repository navigation
Report an empty document as empty rather than unparseable [patch] - #200
Merged
Merged
Conversation
The broad catch added in b256a0e already keeps an empty file from crashing the editor, but it reported the deserializer's argument exception: "is not a document this editor understands: Value cannot be null or whitespace". Check for empty or whitespace-only content before deserializing and say the file is empty, and pin both cases in Open_ReportsAnEmptyFile. Fixes #121 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ACXyQBPWSqFJuF51Mx6FNh
|
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.



Fixes #121
What changed
The crash the issue describes no longer happens on
main. b256a0e widenedDocumentStore.Loadtocatch (Exception ex) when (ex is not OutOfMemoryException), so theArgumentExceptionfromDeserialize("")doesn't escape the frame any more. What's left is the message. A 0-byte file, which an interrupted save leaves behind, was reported as "… is not a document this editor understands: Value cannot be null or whitespace (Parameter 'yaml')".This PR implements the issue's suggested fix:
LoadreturnsDocumentResult.Failed("{path} is empty.")for empty or whitespace-only content before it calls the deserializer.Open_ReportsAnEmptyFilecovers""and" \n". It asserts thatOpenreturnsfalse, that the status says the file is empty, and that no document path is set.Verification
DocumentStorechange reverted, both new test cases fail on the status message. With it in place, they pass.Coder.Testsuite: 1102 passed, 0 failed.🤖 Generated with Claude Code
https://claude.ai/code/session_01ACXyQBPWSqFJuF51Mx6FNh
Generated by Claude Code