@devries-cameron20 / t3code-1 / commits / c83e78fe07
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): Shift+Return after closed inline code or bold starts a plain line (#36285)

Julius Marminge committed Nov 13, 2026 at 11:44 UTC c83e78fe073db40b17cd6d478a88fe575125bb96
2 files changed +36 -3
apps/web/src/components/ComposerPromptEditorTiptap.input.browser.test.tsx
+25
@@ -599,6 +599,31 @@ describe("Markdown markers around styled text", () => {
599 expected: "**bo**\n**ld** after",
600 marks: { bold: ["bo", "ld"] },
601 },
602 + {
603 + name: "a line break after typed inline code leaves the next line plain",
604 + value: "",
605 + caret: 1,
606 + keys: "`Test`{Shift>}{Enter}{/Shift}f",
607 + expected: "`Test`\nf",
608 + marks: { code: ["Test"] },
609 + },
610 + {
611 + name: "a line break after typed bold leaves the next line plain",
612 + value: "",
613 + caret: 1,
614 + keys: "**Test**{Shift>}{Enter}{/Shift}f",
615 + expected: "**Test**\nf",
616 + marks: { bold: ["Test"] },
617 + },
618 + {
619 + name: "bold turned on after typed bold carries across a line break",
620 + value: "",
621 + caret: 1,
622 + keys: `**Test**${isMacPlatform(navigator.platform) ? "{Meta>}b{/Meta}" : "{Control>}b{/Control}"}{Shift>}{Enter}{/Shift}f`,
623 + expected: "**Test**\n**f**",
624 + // The caret beside f shows it as source.
625 + marks: { bold: ["Test"] },
626 + },
627 {
628 name: "splitting a list item inside bold keeps both halves bold",
629 value: "- **bold** after",
apps/web/src/composer-markdown-source.ts
+11 -3
@@ -221,9 +221,9 @@ function collapseRegion(tr: Transaction, region: TextRange, type: MarkType): voi
221 function collapseMarkdownSource(
222 tr: Transaction,
223 keep: (region: TextRange) => boolean = () => false,
224 -): void {
224 +): TextRange[] {
225 const type = tr.doc.type.schema.marks[MARKDOWN_SOURCE_MARK];
226 - if (!type) return;
226 + if (!type) return [];
227 const regions: TextRange[] = [];
228 for (const region of sourceRegions(tr.doc, type)) {
229 const extended = withAdjacentDelimiters(tr.doc, region);
@@ -235,6 +235,7 @@ function collapseMarkdownSource(
235 if (keep(region)) tr.addMark(region.from, region.to, type.create());
236 else collapseRegion(tr, region, type);
237 }
238 + return regions;
239 }
240
241 function mapSelection(tr: Transaction, selection: Selection, map: (pos: number) => number) {
@@ -248,7 +249,14 @@ function mapSelection(tr: Transaction, selection: Selection, map: (pos: number)
249
250 /** Parses all shown source first, so a command that splits it keeps its styles. */
251 export const collapseShownMarkdownSource: Command = ({ tr }) => {
251 - collapseMarkdownSource(tr);
252 + const { selection } = tr;
253 + const type = tr.doc.type.schema.marks[MARKDOWN_SOURCE_MARK];
254 + const marks = tr.storedMarks ?? selection.$from.marks();
255 + const regions = collapseMarkdownSource(tr);
256 + // A caret after the closing markers is outside the styles, though parsed text there is inclusive.
257 + if (type && selection.empty && regions.some(({ to }) => to === selection.from)) {
258 + tr.setStoredMarks(type.removeFromSet(marks));
259 + }
260 return true;
261 };
262