From d533fffb7372fcd09b7a3aadc5b59ee564e6ef48 Mon Sep 17 00:00:00 2001 From: fixfon <12512757+fixfon@users.noreply.github.com> Date: Tue, 20 Oct 2026 11:22:17 +0300 Subject: [PATCH] fix(shared): inline code like `I/W217:220` no longer renders as a file chip A `:line` suffix skipped the extension check for slash-containing inline code, so spreadsheet cell shorthand such as `I/W217:220` became a file chip that dropped the `I/` prefix and the row range from the visible text. A position still vouches for an extensionless file (`bin/run:12`), but a basename shaped like an A1 cell reference (1-3 letters plus digits) no longer does. --- packages/shared/src/markdownLinks.test.ts | 19 +++++++++++++++++++ packages/shared/src/markdownLinks.ts | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/shared/src/markdownLinks.test.ts b/packages/shared/src/markdownLinks.test.ts index 3a0def815d211..e8ef1fa268c1b 100644 --- a/packages/shared/src/markdownLinks.test.ts +++ b/packages/shared/src/markdownLinks.test.ts @@ -343,3 +343,22 @@ describe("resolveMarkdownFileLinkTarget", () => { ); }); }); + +describe("inlineCodeFilePathCandidate with a position suffix", () => { + it.each([ + ["I/W217:220", null], + ["A/B12:40", null], + ["Sheet/XFD1:2", null], + ["./I/W217:220", "./I/W217:220"], + ["bin/run:12", "bin/run:12"], + ["scripts/deploy:40", "scripts/deploy:40"], + ["docker/Dockerfile:8", "docker/Dockerfile:8"], + ["src/app.ts:10", "src/app.ts:10"], + ["src/app.ts:10:4", "src/app.ts:10:4"], + ])( + "only treats extensionless %s as a file when it is not a spreadsheet cell", + (source, candidate) => { + expect(inlineCodeFilePathCandidate(source)).toBe(candidate); + }, + ); +}); diff --git a/packages/shared/src/markdownLinks.ts b/packages/shared/src/markdownLinks.ts index 941f26f55c44b..86dbcb2041e50 100644 --- a/packages/shared/src/markdownLinks.ts +++ b/packages/shared/src/markdownLinks.ts @@ -27,6 +27,7 @@ const PATH_SEPARATOR_PATTERN = /[\\/]/; const FILE_EXTENSION_PATTERN = /\.[A-Za-z0-9_-]+$/; const VERSION_SUFFIX_PATTERN = /\d\.\d[^.]*$/; +const SPREADSHEET_CELL_PATTERN = /^[A-Za-z]{1,3}\d+$/; const NUMERIC_DOTTED_PATTERN = /^\d+(?:\.\d+)+$/; const POSIX_FILE_ROOT_PREFIXES = [ @@ -184,7 +185,14 @@ export function inlineCodeFilePathCandidate(codeText: string): string | null { .split(/[\\/]/) .at(-1) ?? ""; if (VERSION_SUFFIX_PATTERN.test(basename)) return null; - if (!hasPosition && !FILE_EXTENSION_PATTERN.test(basename)) return null; + // A position vouches for an extensionless file (`bin/run:12`), but not for + // spreadsheet cell shorthand (`I/W217:220`). + if ( + !FILE_EXTENSION_PATTERN.test(basename) && + (!hasPosition || SPREADSHEET_CELL_PATTERN.test(basename)) + ) { + return null; + } } return candidate; }