Skip to content

Commit 4ca0dfb

Browse files
committed
fix(terminal): stop link hover regex from swallowing trailing CJK text
The clickable-link regex in TierTerminal used [^\s<>()"'] which lets the match keep eating non-ASCII chars after a URL, so a sentence like "https://x.json,看到一大堆 JSON" highlighted the URL plus all the trailing Chinese as one giant link. URLs are ASCII per RFC 3986. Adding the U+0080–U+FFFF range to the negated set makes the regex stop at the first non-ASCII char without breaking Windows file paths (those keep the looser set so D:\桌面\foo.txt still matches). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5c010b5 commit 4ca0dfb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src-ui/src/components/center/TierTerminal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,11 @@ function TierTerminalImpl({
522522
// Underlines matched tokens on hover; click opens via Tauri's open_url
523523
// command (delegates to the OS shell — system browser for URLs, default
524524
// handler for local files like report.html).
525-
const LINK_RE = /(https?:\/\/[^\s<>()"']+|file:\/\/\/[^\s<>()"']+|[A-Za-z]:[/\\][^\s<>()"']+)/g;
525+
// URLs are ASCII per RFC 3986; the €-￿ guard stops the match at
526+
// any non-ASCII char so trailing CJK punctuation/text (e.g. "https://x,看到…")
527+
// doesn't get swallowed into the link. File paths keep the looser set so
528+
// Windows paths with Chinese folder names still match.
529+
const LINK_RE = /(https?:\/\/[^\s<>()"'€-￿]+|file:\/\/\/[^\s<>()"'€-￿]+|[A-Za-z]:[/\\][^\s<>()"']+)/g;
526530
term.registerLinkProvider({
527531
provideLinks(bufferLineNumber, callback) {
528532
const line = term.buffer.active.getLine(bufferLineNumber - 1);

0 commit comments

Comments
 (0)