fix: preserve TOML decorations/comments across set mutations - #12
Merged
Conversation
- Import Array from toml_edit to enable array editing support - Refactor set_value to route path mutations through array index handling or table-like handling - Introduce helper handle_array_path to manage insert, replace, or remove for array items - Introduce helper handle_tablelike_path to manage table-like mutations with inline table awareness - Add insert_into_value_array to centralize insertion logic for ordinary arrays and handle value decoration - Add insert_into_aot to handle insertion into arrays of tables with proper type checks - Implement index bounds checks that return precise errors including the parent path - Add remove_existing_array_item and remove_array_item_and_fix_format to cleanly remove items and fix formatting - Add preserve_existing_value_decor to keep original decorations when replacing existing values - Extend insert_tablelike logic to properly handle existing keys, inline tables, and associated decorations - Add remove_inline_table_key_and_clean_comments to safely remove a key from an inline table and normalize remaining keys - Refactor update_existing_tablelike_key and related code to manage inline table cleanup and key decoration consistently Signed-off-by: rainbowatcher <rainbow-w@qq.com>
Closed
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.
Summary
Validation
Notes