Rework showDiff to use smart diffing; --show-unchanged; system prompt whitespace fix#424
Rework showDiff to use smart diffing; --show-unchanged; system prompt whitespace fix#424
Conversation
… whitespace fix + --show-unchanged + a fix for lspSupport replacement diffing + preserve original leading and trailing whitespace when applying system prompts
📝 WalkthroughWalkthroughThis pull request introduces diff visualization capabilities by adding a Changes
Sequence DiagramsequenceDiagram
participant CLI as CLI Interface
participant Utils as Feature Flags<br/>(utils.ts)
participant Patch as Patch Operation
participant GlobalReplace as globalReplace()
participant ShowDiff as showDiff()
participant Console as Console Output
CLI->>Utils: --show-unchanged flag received
Utils->>Utils: enableShowUnchanged()<br/>(set isShowUnchangedOn = true)
Patch->>GlobalReplace: Call globalReplace(content, pattern, replacement)
GlobalReplace->>GlobalReplace: Collect all matches<br/>(preserve indices)
GlobalReplace->>GlobalReplace: Apply replacements<br/>in reverse order
GlobalReplace->>ShowDiff: For each replacement:<br/>showDiff(old, new, ...)
ShowDiff->>ShowDiff: Check isShowUnchanged()<br/>and isVerbose()
alt Verbose Mode Enabled
ShowDiff->>ShowDiff: Compute word-level diff<br/>with Unicode normalization
ShowDiff->>ShowDiff: Build context window<br/>around change
ShowDiff->>Console: Output colored diff<br/>(red for removals,<br/>green for additions)
end
GlobalReplace-->>Patch: Return modified content
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes The review requires careful examination of new Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
showDiffnow diffs the old and new input substrings to provide accurate diffing for system prompts, many of which often don't change--show-unchangedto show all patches, even ones where the old and new substring are the samefixLspSupport.ts'sshowDiffusage was incorrect.Summary by CodeRabbit
New Features
--show-unchangedCLI option to display unchanged diffs when used with--verboseImprovements
✏️ Tip: You can customize this high-level summary in your review settings.