diff --git a/src/tools/hashline-edit/constants.ts b/src/tools/hashline-edit/constants.ts index 4ecf66c4..2eac4d9c 100644 --- a/src/tools/hashline-edit/constants.ts +++ b/src/tools/hashline-edit/constants.ts @@ -7,5 +7,4 @@ export const HASHLINE_DICT = Array.from({ length: 256 }, (_, i) => { }) export const HASHLINE_REF_PATTERN = /^([0-9]+)#([ZPMQVRWSNKTXJBYH]{2})$/ -export const HASHLINE_OUTPUT_PATTERN = /^([0-9]+)#([ZPMQVRWSNKTXJBYH]{2}):(.*)$/ -export const HASHLINE_LEGACY_REF_PATTERN = /^([0-9]+):([0-9a-fA-F]{2,})$/ +export const HASHLINE_OUTPUT_PATTERN = /^([0-9]+)#([ZPMQVRWSNKTXJBYH]{2})\|(.*)$/ diff --git a/src/tools/hashline-edit/validation.test.ts b/src/tools/hashline-edit/validation.test.ts index fc401cbf..cf2457ab 100644 --- a/src/tools/hashline-edit/validation.test.ts +++ b/src/tools/hashline-edit/validation.test.ts @@ -61,46 +61,3 @@ describe("validateLineRef", () => { .toThrow(/>>>\s+2#[ZPMQVRWSNKTXJBYH]{2}\|two/) }) }) - -describe("legacy LINE:HEX backward compatibility", () => { - it("parses legacy LINE:HEX ref", () => { - //#given - const ref = "42:ab" - - //#when - const result = parseLineRef(ref) - - //#then - expect(result).toEqual({ line: 42, hash: "ab" }) - }) - - it("parses legacy LINE:HEX ref with uppercase hex", () => { - //#given - const ref = "10:FF" - - //#when - const result = parseLineRef(ref) - - //#then - expect(result).toEqual({ line: 10, hash: "FF" }) - }) - - it("legacy ref fails validation with hash mismatch, not parse error", () => { - //#given - const lines = ["function hello() {"] - - //#when / #then - expect(() => validateLineRef(lines, "1:ab")).toThrow(/>>>\s+1#[ZPMQVRWSNKTXJBYH]{2}\|/) - }) - - it("extracts legacy ref from content with markers", () => { - //#given - const ref = ">>> 42:ab|const x = 1" - - //#when - const result = parseLineRef(ref) - - //#then - expect(result).toEqual({ line: 42, hash: "ab" }) - }) -}) diff --git a/src/tools/hashline-edit/validation.ts b/src/tools/hashline-edit/validation.ts index f81ccbaa..72a33286 100644 --- a/src/tools/hashline-edit/validation.ts +++ b/src/tools/hashline-edit/validation.ts @@ -1,5 +1,5 @@ import { computeLineHash } from "./hash-computation" -import { HASHLINE_REF_PATTERN, HASHLINE_LEGACY_REF_PATTERN } from "./constants" +import { HASHLINE_REF_PATTERN } from "./constants" export interface LineRef { line: number @@ -13,16 +13,13 @@ interface HashMismatch { const MISMATCH_CONTEXT = 2 -const LINE_REF_EXTRACT_PATTERN = /([0-9]+#[ZPMQVRWSNKTXJBYH]{2}|[0-9]+:[0-9a-fA-F]{2,})/ +const LINE_REF_EXTRACT_PATTERN = /([0-9]+#[ZPMQVRWSNKTXJBYH]{2})/ function normalizeLineRef(ref: string): string { const trimmed = ref.trim() if (HASHLINE_REF_PATTERN.test(trimmed)) { return trimmed } - if (HASHLINE_LEGACY_REF_PATTERN.test(trimmed)) { - return trimmed - } const extracted = trimmed.match(LINE_REF_EXTRACT_PATTERN) if (extracted) { @@ -41,13 +38,6 @@ export function parseLineRef(ref: string): LineRef { hash: match[2], } } - const legacyMatch = normalized.match(HASHLINE_LEGACY_REF_PATTERN) - if (legacyMatch) { - return { - line: Number.parseInt(legacyMatch[1], 10), - hash: legacyMatch[2], - } - } throw new Error( `Invalid line reference format: "${ref}". Expected format: "LINE#ID" (e.g., "42#VK")` )