refactor(hashline-edit): remove HASHLINE_LEGACY_REF_PATTERN and legacy ref compat
Remove the old LINE:HEX (e.g. "42:ab") reference format support. All refs now use LINE#ID format exclusively (e.g. "42#VK"). Also fixes HASHLINE_OUTPUT_PATTERN to use | separator (was missed in PR #2079).
This commit is contained in:
@@ -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")`
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user