The best way to control Claude Code, Codex and more from any computer or phone
fix(web): composer drafts keep underscores in non-Latin names (#37495)
Co-authored-by: yzn-h <63852512+yzn-h@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
tiliakoos committed
Nov 16, 2026 at 01:08 UTC
3cf00c3e8b9facb1c506efc186e636a999b27c60
2 files changed
+13
-3
apps/web/src/composer-rich-text.test.ts
+5
@@ -7,6 +7,9 @@ describe("composer rich text markdown", () => {
7
for (const text of [
8
"plain text",
9
"snake_case",
10
+ "ملفٌ_اول و ملفٌ_ثاني",
11
+ "файл_один и файл_два",
12
+ "𐐀_𐐁_𐐂 and 𠀀_𠀁_𠀂",
13
"unmatched **",
14
"** spaced **",
15
"\\*literal\\*",
@@ -72,6 +75,8 @@ describe("composer rich text markdown", () => {
75
["__see src/__a.ts__(optional)", "see src/__a.ts", "bold", "(optional)"],
76
["_see src/_a.ts_.", "see src/_a.ts", "italic", "."],
77
["_notes.md_ here", "notes.md", "italic", " here"],
78
+ ["_файл_один.py_ now", "файл_один.py", "italic", " now"],
79
+ ["_my_file.py is broken_ now", "my_file.py is broken", "italic", " now"],
80
["_e.g._ this", "e.g.", "italic", " this"],
81
["_and_/or", "and", "italic", "/or"],
82
] as const) {
apps/web/src/composer-rich-text.ts
+8
-3
@@ -28,6 +28,9 @@ const PATH_TOKEN = /(?:[\p{L}\p{N}_/.:@%+=&?#-]|(?<!~)~(?!~))+/gu;
28
const FILE_EXTENSION = /^\.[a-z][a-z0-9]*(?::\d+){0,2}$/i;
29
// `_yes_/_no_`: each side of a slash is its own emphasis span, so the word is not a path.
30
const EMPHASIS_ALTERNATIVES = /^_[^/]+_(?:\/_[^/]+_)+$/;
31
+// Word characters in any script; callers pass two code units so a letter outside the BMP matches whole.
32
+const WORD_CHARACTER_BEFORE = /[\p{L}\p{M}\p{N}_]$/u;
33
+const WORD_CHARACTER_AFTER = /^[\p{L}\p{M}\p{N}_]/u;
34
35
/**
36
* Starts of underscore runs that belong to a URL, path, or filename, not to emphasis.
@@ -55,7 +58,7 @@ function literalUnderscoreRuns(text: string): Set<number> {
58
while (body[end] === "_") end += 1;
59
if (start > 0) {
60
literal.add(match.index + start);
58
- closesInside ||= !/\w/.test(body[end]!);
61
+ closesInside ||= !WORD_CHARACTER_AFTER.test(body.slice(end, end + 2));
62
}
63
start = body.indexOf("_", end);
64
}
@@ -118,8 +121,10 @@ function parseInlineMarkdownPieces(text: string): SourcePiece[] {
121
}
122
const before = text[index - 1] ?? "";
123
const after = text[end] ?? "";
121
- const canClose = before !== "" && !/\s/.test(before) && (char !== "_" || !/\w/.test(after));
122
- const canOpen = after !== "" && !/\s/.test(after) && (char !== "_" || !/\w/.test(before));
124
+ const wordAfter = WORD_CHARACTER_AFTER.test(text.slice(end, end + 2));
125
+ const wordBefore = WORD_CHARACTER_BEFORE.test(text.slice(Math.max(0, index - 2), index));
126
+ const canClose = before !== "" && !/\s/.test(before) && (char !== "_" || !wordAfter);
127
+ const canOpen = after !== "" && !/\s/.test(after) && (char !== "_" || !wordBefore);
128
while (index < end) {
129
const top = stack.at(-1);
130
const opensNestedBold =