Skip to content

Keep a lone list property's key when merging properties [patch] - #173

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/147-asis-list-keys
Sep 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/147-asis-list-keys

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #147

What changed

PropertyMerger.MergePropertyGroup sent every list-valued group to MergeArrayValues, and that method always writes to the canonical key. So a lone list with nothing to merge was still renamed, even with FrontmatterNaming.AsIs: section: became categories:, keywords became tags, and category became categories.

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_MergeUnderOneNameWithBothValues already 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:

  • CombineFrontmatter with AsIs naming keeps a lone section list under every merge strategy (the scenario from the issue)
  • MergeSimilarProperties keeps a lone keywords or category list under its own key

Results:

  • With the fix: 219/219 pass (dotnet test)
  • With PropertyMerger.cs reverted: 5 of the new tests fail (the None strategy row already passed)

🤖 Generated with Claude Code

https://claude.ai/code/session_01AFCuHRLN6NWMQ4DJNZApHa


Generated by Claude Code

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
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 582547f into main Sep 30, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/147-asis-list-keys branch September 30, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

With FrontmatterNaming.AsIs, merging still renames a lone list property to its canonical key (e.g. section: list becomes categories:)

2 participants