Repository navigation
fix(web): wrapping a selection in backticks formats it as code - #14870
SepehrRajabi wants to merge 3 commits into
Conversation
In the rich text composer, typing ` * or _ over a selection inserted literal markers instead of applying the code or italic mark, unlike typing the markers around the text. Apply the mark instead; plain mode keeps literal wrapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Would Approve Macroscope's review found this PR approvable — This is a small, self-contained composer bug fix that applies existing rich-text marks while preserving literal behavior in plain mode. A Medium-severity issue remains for selections spanning lines or paragraphs, where serialization can change formatting boundaries. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
Inline marks cannot cross lines in markdown, so marking a multi-line selection serialized as one span per line. Fall back to literal markers instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pingdotgg/t3code/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe composer now attempts to apply a code or italic mark to selected text when a supported opener is typed. If the selection cannot be marked, the existing closer-insertion behavior continues. ChangesSelection Marking
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The selection-formatting change appears mergeable after normal checks; no concrete issue remains identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Problem
With rich text on, selecting text in the composer and pressing
`wraps the selection in literal backticks instead of formatting it as inline code. Typing`text`by hand formats it correctly.*and_have the same problem with italic.To reproduce: turn on rich text, type
say hello now, selecthello, press`. The composer shows`hello`as plain text instead of code.Change
The wrap-selection handler is an
editorProps.handleTextInput. ProseMirror calls it before plugin handlers, so Tiptap's mark input rules never get to run. It wrapped the selection in literal markers and stopped there.A new
surroundSelectionWithMarkhelper incomposer-rich-text-doc.tsnow applies thecodemark for`and theitalicmark for*and_. The result matches what typing the markers produces. The helper returnsnull, and the selection is still wrapped in literal characters, in two cases: in plain mode, where those marks don't exist, and when the selection spans more than one line (separate paragraphs or a line break). Inline markdown can't cross lines, so marking that text would save as one span per line, changing`one\ntwo`into`one`\n`two`. Brackets and quotes keep wrapping as before, and the existing guards still apply: already-styled text, chips, and mention boundaries are left to normal typing.Scope and approval
This is a very small, focused fix for an obvious bug. The same keystroke gives different results depending on whether you wrap a selection or type the markers yourself. It changes one handler in the web composer and adds a pure helper with tests. It doesn't depend on the provider, and the mobile composer has no wrap-selection behaviour.
Verification
vp test run src/composer-rich-text-doc.test.ts(inapps/web): 87 passed. The new cases build a document, apply the helper to thehelloselection, and serialize it back to markdown:`givessay `hello` now*and_givesay *hello* nownull, so wrapping stays literalnull, so wrapping stays literalvpr typecheckinapps/webandvp linton the changed files: clean.Rename the parseConfig helper, selectedparseConfig, pressed`.main)Before, the composer kept literal
`parseConfig`as plain text. After,parseConfigrenders as inline code, the same as typing the backticks by hand. I didn't check the multi-line fallback manually; the unit tests cover it.Model: Claude Opus 5.5, via Claude Code running in T3 Code.
🤖 Generated with Claude Code