Skip to content

Fix ChangePropertyKey whitespace quirks when moving subproperties#7283

Merged
timtebeek merged 1 commit intomainfrom
tim/issue-2608-yaml-merge
Apr 6, 2026
Merged

Fix ChangePropertyKey whitespace quirks when moving subproperties#7283
timtebeek merged 1 commit intomainfrom
tim/issue-2608-yaml-merge

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Apr 6, 2026

Summary

When ChangePropertyKey moves a nested subproperty to a new top-level key (e.g. renaming foo.barbar), the DeletePropertyVisitor unconditionally cleared the surviving entry's prefix to "" when a mapping was reduced to one entry. This lost positional whitespace context, causing:

  • A spurious leading newline when the property was in the first document entry
  • A missing newline after --- in multi-document YAML (producing ---other: val instead of ---\nother: val)

The fix preserves the original first entry's prefix instead of clearing it, which carries the correct positional context in all cases.

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Apr 6, 2026
@timtebeek timtebeek merged commit 0c866ba into main Apr 6, 2026
1 check passed
@timtebeek timtebeek deleted the tim/issue-2608-yaml-merge branch April 6, 2026 10:15
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Yaml/ChangePropertyKey - whitespace quirks

1 participant