Keep a lone list property's key when merging properties [patch] - #173
Merged
Merged
Conversation
MergeArrayValues always wrote the list under its canonical key, even when the group held a single key and nothing was merged, so with FrontmatterNaming.AsIs a lone 'section' list still became 'categories' (and 'keywords' became 'tags'). A lone list now passes through under its own key, the same as a scalar; lists that really are merged still land under the canonical key. Fixes #147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFCuHRLN6NWMQ4DJNZApHa
|
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 #147
What changed
PropertyMerger.MergePropertyGroupsent every list-valued group toMergeArrayValues, and that method always writes to the canonical key. So a lone list with nothing to merge was still renamed, even withFrontmatterNaming.AsIs:section:becamecategories:,keywordsbecametags, andcategorybecamecategories.A list group with only one key now takes the scalar branch and keeps its original key. Groups where several list keys really are merged still land under the canonical key.
EquivalentKeyMergeTests.EquivalentListKeys_MergeUnderOneNameWithBothValuesalready covers and expects that behaviour, so this PR leaves it alone.I left one thing from the issue's acceptance criteria unchanged: multi-key scalar groups still use
originalKeys[0]while multi-key list groups use the canonical key. Making them use the same key would change behaviour that existing tests expect, so it deserves its own decision rather than riding on this bug fix.Tests
Frontmatter.Test/ListKeyNamingTests.cs:CombineFrontmatterwith AsIs naming keeps a lonesectionlist under every merge strategy (the scenario from the issue)MergeSimilarPropertieskeeps a lonekeywordsorcategorylist under its own keyResults:
dotnet test)PropertyMerger.csreverted: 5 of the new tests fail (theNonestrategy row already passed)🤖 Generated with Claude Code
https://claude.ai/code/session_01AFCuHRLN6NWMQ4DJNZApHa
Generated by Claude Code