Skip to content

Commit 5595c33

Browse files
test(shared): keep the line-range assertions that fail on main
formatFilePathPosition now asserts the end line, which main drops. Path resolve, markdown label rows, and the web wrapper already passed. The mobile icon suffix never receives a raw range, and editors parse the rewritten launch path once.
1 parent 6a02512 commit 5595c33

5 files changed

Lines changed: 11 additions & 22 deletions

File tree

‎apps/mobile/src/lib/markdownLinks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { videoMimeType } from "@t3tools/shared/video";
1010

1111
import type { MARKDOWN_FILE_ICON_SOURCES } from "./markdownFileIcons.generated";
1212

13-
const POSITION_SUFFIX_PATTERN = /:\d+(?::\d+|-\d+)?$/;
13+
const POSITION_SUFFIX_PATTERN = /:\d+(?::\d+)?$/;
1414

1515
export type MarkdownLinkPresentation =
1616
| {

‎apps/server/src/process/externalLauncher.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ function resolveCommandEditorArgs(
147147
Option.isSome(parsedTarget) && Option.isSome(parsedTarget.value.endLine)
148148
? `${parsedTarget.value.path}:${parsedTarget.value.line}`
149149
: target;
150-
const parsedLaunchTarget =
151-
launchTarget === target ? parsedTarget : parseTargetPathAndPosition(launchTarget);
150+
const parsedLaunchTarget = parseTargetPathAndPosition(launchTarget);
152151

153152
switch (editor.launchStyle) {
154153
case "direct-path":

‎apps/web/src/markdown-links.test.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,11 @@ describe("resolveInlineCodeFileLinkMeta", () => {
6262
targetPath: "/Users/julius/project/script.ts:10",
6363
line: 10,
6464
});
65-
expect(resolveInlineCodeFileLinkMeta("foo.py:67-69", "/Users/julius/project")).toMatchObject({
66-
filePath: "/Users/julius/project/foo.py",
67-
targetPath: "/Users/julius/project/foo.py:67-69",
68-
line: 67,
69-
endLine: 69,
70-
});
7165
expect(resolveInlineCodeFileLinkMeta("AGENTS.md", "/Users/julius/project")).toBeNull();
7266
});
7367

7468
it("does not treat arbitrary name:digits shapes as files", () => {
7569
expect(resolveInlineCodeFileLinkMeta("error:1", "/Users/julius/project")).toBeNull();
76-
expect(resolveInlineCodeFileLinkMeta("error:1-3", "/Users/julius/project")).toBeNull();
7770
expect(resolveInlineCodeFileLinkMeta("TODO:12", "/Users/julius/project")).toBeNull();
7871
expect(resolveInlineCodeFileLinkMeta("exit:0", "/Users/julius/project")).toBeNull();
7972
expect(resolveInlineCodeFileLinkMeta("port:3000", "/Users/julius/project")).toBeNull();

‎packages/shared/src/fileLinks.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from "vite-plus/test";
22
import {
33
fileLinkLabel,
4+
formatFilePathPosition,
45
parseFileUrlHref,
56
splitFilePathPosition,
67
resolvePathLinkTarget,
@@ -50,6 +51,14 @@ describe("splitFilePathPosition", () => {
5051
});
5152
});
5253

54+
describe("formatFilePathPosition", () => {
55+
it("keeps a colon range on the target", () => {
56+
expect(formatFilePathPosition({ path: "src/foo.py", line: 67, endLine: 69 })).toBe(
57+
"src/foo.py:67-69",
58+
);
59+
});
60+
});
61+
5362
describe("fileLinkLabel", () => {
5463
it("shows a colon range as a line span", () => {
5564
expect(fileLinkLabel({ path: "/tmp/locomo.py", line: 67, endLine: 69 }, new Map())).toBe(
@@ -72,7 +81,6 @@ describe("resolvePathLinkTarget", () => {
7281
String.raw`\\server\share\project\.\src\index.ts:12`,
7382
],
7483
["src/index.ts:12", "/home/jane/project", "/home/jane/project/src/index.ts:12"],
75-
["src/foo.py:67-69", "/home/jane/project", "/home/jane/project/src/foo.py:67-69"],
7684
])("resolves %s using the connected environment cwd %s", (path, cwd, expected) => {
7785
expect(resolvePathLinkTarget(path, cwd)).toBe(expected);
7886
});

‎packages/shared/src/markdownLinks.test.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ describe("isMarkdownFileLinkLabel", () => {
1414
["validates the input", "/repo/src/example.ts:12", false],
1515
["example.ts:12", "/repo/src/example.ts:12", true],
1616
["example.ts:99", "/repo/src/example.ts:12", false],
17-
["example.ts:10-12", "/repo/src/example.ts:10-12", true],
18-
["example.ts:10-20", "/repo/src/example.ts:10-12", false],
1917
])("classifies %s for %s", (label, href, expected) => {
2018
expect(isMarkdownFileLinkLabel(label, href)).toBe(expected);
2119
});
@@ -75,11 +73,6 @@ describe("parseMarkdownFileLink", () => {
7573
});
7674

7775
it("reads a colon line range separately from the filename", () => {
78-
expect(parseMarkdownFileLink("/tmp/pyproject.toml:1-3")).toEqual({
79-
path: "/tmp/pyproject.toml",
80-
line: 1,
81-
endLine: 3,
82-
});
8376
expect(parseMarkdownFileLink("src/foo.py:67-69")).toEqual({
8477
path: "src/foo.py",
8578
line: 67,
@@ -142,10 +135,6 @@ describe("resolveMarkdownFileLinkTarget", () => {
142135
expect(resolveMarkdownFileLinkTarget("script.ts:67-69", "/Users/julius/project")).toBe(
143136
"/Users/julius/project/script.ts:67-69",
144137
);
145-
expect(resolveMarkdownFileLinkTarget("/tmp/pyproject.toml:1-3")).toBe(
146-
"/tmp/pyproject.toml:1-3",
147-
);
148-
expect(resolveMarkdownFileLinkTarget("TODO:12-14", "/Users/julius/project")).toBeNull();
149138
});
150139

151140
it("maps #L line anchors to editor line suffixes", () => {

0 commit comments

Comments
 (0)