From 25da5596a94a75c6ec99f234bdf4e23121b34839 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 18 Jun 2026 08:56:19 -0400 Subject: [PATCH] fix: Inline code marks longer than the width of editor escape (#12735) --- shared/editor/components/Styles.ts | 5 ++++- shared/editor/plugins/CodeWordDecorationsPlugin.ts | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/shared/editor/components/Styles.ts b/shared/editor/components/Styles.ts index bc8b8dcdb0..ee3a62ceb6 100644 --- a/shared/editor/components/Styles.ts +++ b/shared/editor/components/Styles.ts @@ -1752,11 +1752,14 @@ code { font-family: ${props.theme.fontFamilyMono}; font-size: 90%; + &.inline { + color: ${props.theme.codeKeyword}; + } + .${EditorStyleHelper.codeWord} { @media (min-width: ${breakpoints.tablet}px) { white-space: nowrap; } - color: ${props.theme.codeKeyword}; } } diff --git a/shared/editor/plugins/CodeWordDecorationsPlugin.ts b/shared/editor/plugins/CodeWordDecorationsPlugin.ts index a398e2c78b..365f6a2bf2 100644 --- a/shared/editor/plugins/CodeWordDecorationsPlugin.ts +++ b/shared/editor/plugins/CodeWordDecorationsPlugin.ts @@ -9,12 +9,15 @@ import { EditorStyleHelper } from "../styles/EditorStyleHelper"; interface CodeWordDecorationsConfig { /** CSS class to apply to word decorations */ className?: string; + /** Tokens longer than this many characters are left unwrapped so they break */ + maxWordLength?: number; } class CodeWordDecorationsPlugin extends Plugin { constructor(config: CodeWordDecorationsConfig = {}) { const defaultConfig: Required = { className: EditorStyleHelper.codeWord, + maxWordLength: 40, }; const finalConfig = { ...defaultConfig, ...config }; @@ -102,7 +105,10 @@ class CodeWordDecorationsPlugin extends Plugin { for (let i = 0; i < words.length; i++) { const word = words[i]; - if (word.length > 0) { + // Tokens longer than a line cannot move to the next line as a unit, + // so leave them unwrapped to inherit the editor's default breaking + // rather than overflow. + if (word.length > 0 && word.length <= config.maxWordLength) { const wordStart = currentPos; const wordEnd = wordStart + word.length;