Skip to content

Keep whole character after a backslash in RTF outline import - #1454

Merged
aiongg merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h3020-rtf-outline-import-drops-the-res
Nov 4, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h3020-rtf-outline-import-drops-the-res

Conversation

@Silvertree2010

@Silvertree2010 Silvertree2010 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Found while testing crates/format/src/rtf.rs:301-326 (symbol / text, reached via escape) (no existing issue): RTF outline import drops the rest of a paragraph after a backslash followed by a multi-byte character.

Cause

In rtf_to_outline, symbol() advanced the cursor by one byte. For a backslash followed by a multi-byte character, that left the cursor inside the UTF-8 character. The next text() run then started at a non-character boundary, rtf.get(..) returned None, and the text up to the next special character was silently dropped.

Fix

symbol() now advances past the whole character using the existing boundary-aware advance() helper. For a non-ASCII control symbol it also emits that character, so A\éB imports as AéB.

Verified

  • Regression test rtf::tests::multibyte_control_symbol_keeps_character_and_following_text: fails on main without the fix and passes with it (cargo test -p deckcraft-format multibyte_control_symbol_keeps_character_and_following_text).
  • cargo xtask ci passes except backstage::tests::start_screen_opens_the_palette_and_preferences, which also fails on main without this change.

Not changed

Unknown ASCII control symbols are still ignored. I made no other changes to RTF parsing.

🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models

Summary by CodeRabbit

  • Bug Fixes
    • RTF outlines now preserve non-ASCII symbols and the text that follows them, including symbols represented by multiple bytes. This prevents multibyte characters from being split or omitted when reading outline content.

Found while testing crates/format/src/rtf.rs:301-326 (symbol / text, reached via escape)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between ee875ab and d8936f9.

Files selected for processing: 1
  • crates/format/src/rtf.rs

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

Walkthrough

Outline::symbol advances over complete UTF-8 characters and retains non-ASCII control symbols in the parsed outline. A regression test checks that a multibyte symbol and following text are preserved.

Changes: RTF outline parsing

Layer / File(s) Summary
UTF-8 symbol parsing
crates/format/src/rtf.rs
Outline::symbol advances by the next character’s UTF-8 byte length and appends non-ASCII control symbols. A regression test checks that the symbol and following text are retained.

Priority: Normal

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

Change: Bug fix

Suggested reviewers: dylanmtaylor

Merge Risk: Minimal · up to d8936

No actionable merge risk remains; the focused test could not run only because no Rust toolchain was configured.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… 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 describes the fix: preserving the complete character after a backslash during RTF outline import.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

@Harrison-Booth

Copy link
Copy Markdown
Contributor

Review notes (comment only). Read the diff and ran cargo test -p deckcraft-format --lib rtf on the PR head with CARGO_BUILD_JOBS=2 on Linux: all 10 RTF tests pass, including the new multibyte control symbol test. advance() is the same boundary-aware helper the other paths use, so the cursor no longer lands inside a UTF-8 character. Keeping the character after \é (rather than dropping it) is a judgement call that matches what the PR describes. Not checked: how PowerPoint or Word treat a raw non-ASCII byte after a backslash (not run via COM); Windows/macOS not run (platform independent code).

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewerA — source-read COMMENT (not an approval)

I read the whole diff: after a backslash the RTF outline reader now advances by a whole UTF-8 character (advance) and keeps that character, instead of stepping one byte into the middle of it, with a test (A\éB). Correct and safe on char boundaries (get(i..) returns None otherwise).

I ran nothing and have no exact-head CI result for this PR, so this is not an approval.

Status: waiting_author.

@aiongg aiongg added the bugfix Fixes something that is broken: wrong result, crash, data loss label Nov 4, 2026
@aiongg aiongg self-assigned this Nov 4, 2026
@aiongg
aiongg merged commit c252a68 into storytold:main Nov 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants