Repository navigation
fix(stringify): use indentStep length for mapping block scalar indent indicator - #738
Open
princejain756 wants to merge 1 commit into
Open
princejain756 wants to merge 1 commit into
princejain756 wants to merge 1 commit into
Conversation
… indicator When a block scalar starts with a space and is serialized inside a mapping or set, its content is indented by `ctx.indentStep` relative to its parent node. Previously `blockString()` hardcoded `'2'` whenever `indent` was non-empty, causing `stringify()` with `indent` other than 2 to emit an indentation indicator that disagreed with the content indentation. Reset `implicitKey` to `undefined` for block sequence items (which always indent by 2 spaces relative to `-`) and use `ctx.indentStep.length` when `ctx.implicitKey === false`. Fixes eemeli#733
This branch has not been deployed
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.
Issue
fixes #733
LLM Use
An LLM coding assistant helped draft the fix, the tests, and this description. I reviewed the change, ran the test suite locally, and verified the output by hand for indent values 1, 2, and 4.
Description
blockString()hardcoded the indentation indicator'2'whenever a block scalar's first line started with a space and the serialization context had non-emptyindent. For mapping (and set) values the content is actually indented byctx.indentStep, sostringify()called withindentother than 2 wrote an indicator that disagreed with the emitted content and produced output that did not re-parse to the same document.The fix resets
implicitKeytoundefinedfor block sequence items (whose scalar content always indents by 2 relative to the-marker) and usesctx.indentStep.lengthwhen serializing inside a mapping or set, so the indicator matches the real content indent for anyindentvalue.Regression tests cover indent 1, 2, and 4 for mapping values, set values, and block sequence items.