Skip to content

Keep repeated items within a list when merging properties - #144

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/keep-repeated-list-items
Sep 27, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/keep-repeated-list-items

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #142

What was wrong

PropertyMerger.MergeArrayValues put every list into one HashSet<object>. That removed duplicates across the lists being merged, as intended, but it also removed them within a single list. Every key goes through the merger, singleton groups included, so CombineFrontmatter with the default Conservative strategy turned steps: [mix, wait, mix] into [mix, wait] on a single-block document where nothing was being merged.

Change

Lists are now appended in order. An item is dropped only when an earlier list in the same merge already supplied it. Repeats inside one list are always kept. The approach follows the issue's acceptance criteria.

  • A singleton list passes through unchanged.
  • tags: [a, a, c] merged with tag: [b, c, b] gives tags: [a, a, c, b, b]: c from tag is dropped because tags already supplied it.

Singleton list keys still take their canonical name, as before (for example tag → tags). This PR changes only which list items survive.

Tests

PropertyMergerTests gains three tests:

  • A singleton list with repeats keeps every item under MergeSimilarProperties.
  • Two merged lists keep their within-list repeats and drop only cross-list duplicates.
  • CombineFrontmatter round-trips steps: [mix, wait, mix] and scores: [1, 1, 2] from a single block.

With the fix reverted, all 3 new tests fail. With the fix, the full suite passes: 156/156.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KMqfUfzWj2Gmdz1EqYdnLe


Generated by Claude Code

MergeArrayValues collected every list into one HashSet, so it removed
duplicates inside a single list as well as across the lists being
merged. Because even singleton keys go through it, CombineFrontmatter
under the default Conservative strategy turned steps: [mix, wait, mix]
into [mix, wait] on a document with nothing to merge.

Lists are now appended in order, and an item is dropped only when an
earlier list in the same merge already supplied it.

Fixes #142

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMqfUfzWj2Gmdz1EqYdnLe
@sonarqubecloud

Copy link
Copy Markdown

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.

CombineFrontmatter silently removes repeated items from every list, even when no keys are being merged

1 participant