Skip to content

[Refactor] Sorting logic to create a wrapper for sorting by postion - #9

Merged
Avni2000 merged 1 commit into
mainfrom
fix-duplicate-ordering
Jan 29, 2026
Merged

Avni2000 merged 1 commit into
mainfrom
fix-duplicate-ordering

Conversation

@Avni2000

@Avni2000 Avni2000 commented Jan 28, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor
    • Consolidated internal sorting logic for cell conflict resolution by introducing shared utility functions for position-based ordering. This improves code maintainability and consistency across the application while preserving existing behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR refactors position-based sorting logic by extracting compareByPosition and sortByPosition utilities from cellMatcher.ts, then consolidates duplicated sorting implementations in ConflictResolverPanel.ts to use these shared helpers. Behavior remains unchanged while centralizing sorting logic.

Changes

Cohort / File(s) Summary
Sorting utilities extraction
src/cellMatcher.ts
Added compareByPosition() and sortByPosition() public utilities to centralize position-based sorting logic. Updated sortMappingsByPosition() to delegate to sortByPosition() rather than inlining comparator logic. Preserves tie-breaking semantics using per-version indices (incoming, current, base).
Sorting consolidation
src/webview/ConflictResolverPanel.ts
Replaced bespoke sort implementation for MergeRow items with call to sortByPosition() utility. Added import for sortByPosition from cellMatcher module. Maintains existing sort behavior through positional key object.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #8: Modifies the same tie-breaking order (incoming → current → base) for position-based sorting in sortMappingsByPosition, making it directly related to this refactoring of the comparison logic.

Poem

🐰 Sorting scattered everywhere—
Now one utility, clean and fair!
Positions compared with grace,
Duplicates vanish without a trace.
Tied-breakers preserved, logic consolidated,
Our little helper, finally celebrated! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring work: extracting position-based sorting logic into reusable utilities (compareByPosition and sortByPosition).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Docstrings were successfully generated.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Avni2000
Avni2000 merged commit 007ff5d into main Jan 29, 2026
@coderabbitai

coderabbitai Bot commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #10

coderabbitai Bot added a commit that referenced this pull request Jan 29, 2026
Docstrings generation was requested by @Avni2000.

* #9 (comment)

The following files were modified:

* `src/cellMatcher.ts`
@Avni2000
Avni2000 deleted the fix-duplicate-ordering branch March 1, 2026 01:40
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.

1 participant