Skip to content

Add ToString override to DiffPiece - #159

Open
Maneet7805 wants to merge 1 commit into
mmanela:masterfrom
Maneet7805:diffpiece-tostring
Open

Maneet7805 wants to merge 1 commit into
mmanela:masterfrom
Maneet7805:diffpiece-tostring

Conversation

@Maneet7805

@Maneet7805 Maneet7805 commented Oct 13, 2026 •

Copy link
Copy Markdown

Fixes #84

Adds a ToString() override to DiffPiece so pieces are readable in the debugger
Handles missing values safely and includes 3 unit tests. All 251 tests pass.
I wrote this with help from an AI assistant and have reviewed and tested it myself.

Summary by CodeRabbit

  • New Features
    • Diff results now have a readable text representation that includes position, sub-piece count, change type, and text. Missing positions are shown as a dash, and the representation remains available when sub-pieces or text are absent. This makes it easier to inspect individual pieces of a diff in text form.

Shows position, sub-piece count, change type and text, so a
DiffPaneModel's Lines are readable in the debugger without expanding
each piece. Null-safe for Position, SubPieces and Text.

Fixes mmanela#84
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7f5b987c-db0b-40a2-9fc1-e2a3d4fe3dd5
📥 Commits

Reviewing files that changed from the base of the PR and between f500e73 and 0311766.

📒 Files selected for processing (2)
  • DiffPlex/DiffBuilder/Model/DiffPiece.cs
  • Facts.DiffPlex/DiffPieceFacts.cs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

DiffPiece now overrides ToString() to include its position, subpiece count, change type, and text. Tests cover formatting with a position and subpieces, a null position, and null subpieces and text.

Changes: DiffPiece string representation

Layer / File(s) Summary
String formatting and tests
DiffPlex/DiffBuilder/Model/DiffPiece.cs, Facts.DiffPlex/DiffPieceFacts.cs
DiffPiece.ToString() includes the position, subpiece count, change type, and text. It uses - when the position is null and 0 when subpieces are null. Tests cover these formats and null text.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 03117

This adds a readable string representation for DiffPiece to help with debugging. No merge-blocking risk was found.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding a ToString override to DiffPiece.
Linked Issues check Passed Issue #84 requests a ToString() override or debugger display for DiffPiece with position, sub-piece count, change type, and text. DiffPlex/DiffBuilder/Model/DiffPiece.cs adds ToString() with a…
Out of Scope Changes check Passed The reviewed changes are limited to the requested DiffPiece.ToString() implementation and supporting unit tests. The implementation and tests directly support issue #84. No unrelated change is shown…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

ToString override on DiffPiece (and possibly others)

1 participant