Repository navigation
Normalise CRLF in replace_text before computing the diff - #1532
h-a-n-a-s-h-i merged 1 commit into
Conversation
Found while testing crates/model/src/edit.rs:420-439 (replace_text), reached from crates/engine/src/cmd/slide.rs:556 (notes) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Normalize text and verify replacement behavior crates/model/src/edit.rs |
replace_text normalizes line endings before computing text differences. Tests check changed text, equivalent normalized text, and formatting on a preserved prefix. |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Suggested reviewers: echelon
Merge Risk: 
Minimal · up to 9e5af
-
The change fixes the extra empty paragraph that appeared when notes were updated with CRLF line endings. A rare edge case remains for notes whose existing runs already contain a raw carriage return, where appended text could lose formatting on later runs. This is not a merge blocker.
Architecture risk: 
Medium · up to 9e5af
-
The change affects 1 system.
Changed systems:
cratesArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — crates (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
- observed — Modified behavior in crates/model/src/edit.rs:
replace_textnow normalizes CRLF and lone CR line endings before computing text differences. - observed — Modified behavior in crates/model/src/edit.rs: Added tests for CRLF handling in
replace_text: changed text produces normalized paragraph breaks, already-normalized equivalent text leaves the body unchanged, and formatting remains on a preserved prefix.
Reliability and maintainability
- inferred — Risk-relevant change factors for crates: blast_radius_2; direct_dependents_2
-
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: replace_text now normalizes CRLF before computing the diff. The raw summary and PR objectives both describe this exact change in crates/model/src/edit.rs, so the title is fully related and specific.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Landed on main, thank you @Silvertree2010 for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft |
Found while testing
crates/model/src/edit.rs:420-439 (replace_text), reached from crates/engine/src/cmd/slide.rs:556 (notes)(no existing issue): replace_text (slide.notes text) adds an empty paragraph when the new text uses CRLF line endings.Cause
replace_textworked out the common prefix and suffix on the raw new text, and onlyinsertturned CRLF into LF later. When the kept suffix started at the\nof a\r\npair, the leftover\rwas part of the inserted text and became an extra paragraph break, so "z\r\ny" gave "z\n\ny".Fix
replace_textnow turns\r\nand lone\rinto\nbefore diffing, the same wayTextBody::from_textdoes. A pair can no longer be split, and the same text with CRLF now leaves the body unchanged. A regression test covers CRLF at the suffix boundary, in the kept prefix and a lone CR.Verified
edit::tests::replace_text_crlf_matches_from_text: fails onmainwithout the fix and passes with it (cargo test -p deckcraft-model --lib replace_text_crlf_matches_from_text).cargo xtask cipasses exceptbackstage::tests::start_screen_opens_the_palette_and_preferences, which also fails onmainwithout this change.Not changed
insertandTextBody::from_textstill do their own line-ending handling, and thetext.setpath is not changed.🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models
Summary by CodeRabbit