Fix MergeYaml Document.End fallback inserting extra blank lines#7311
Merged
Fix MergeYaml Document.End fallback inserting extra blank lines#7311
Conversation
The Document.End prefix fallback introduced in #7291 would copy trailing whitespace (e.g. a bare newline) as a "comment" prefix onto newly merged entries, causing an extra blank line in the output. Only use the Document.End prefix when it actually contains a YAML comment (has a `#` character). Plain trailing whitespace should not be treated as a comment to preserve. Fixes the `SeparateApplicationYamlByProfileTest.mergeIntoExistingProfileFilePreservesFormat` failure in openrewrite/rewrite-spring.
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
MergeYamlVisitor.mergeMapping()to only use the prefix when it actually contains a YAML comment (#character)\n) as a "comment" onto newly merged entries, causing an extra blank line in the outputSeparateApplicationYamlByProfileTest.mergeIntoExistingProfileFilePreservesFormatto fail in openrewrite/rewrite-spring CITest plan
MergeYamlTesttests pass (including the new tests from Fix MergeYaml wildcard, flow-style sequence, and comment handling #7291)rewrite-yamltest suite passesSeparateApplicationYamlByProfileTest.mergeIntoExistingProfileFilePreservesFormatin rewrite-spring passes with this fix