fix(hashline): accept legacy hashes for indented anchors
Keep persisted LINE#ID anchors working after strict whitespace hashing by falling back to the legacy hash for validation-only lookups. Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "bun:test"
|
||||
import { computeLineHash } from "./hash-computation"
|
||||
import { computeLineHash, computeLegacyLineHash } from "./hash-computation"
|
||||
import { parseLineRef, validateLineRef, validateLineRefs } from "./validation"
|
||||
|
||||
describe("parseLineRef", () => {
|
||||
@@ -116,6 +116,15 @@ describe("validateLineRef", () => {
|
||||
expect(() => validateLineRef(lines, "1#ZZ")).toThrow(/>>>\s+1#[ZPMQVRWSNKTXJBYH]{2}\|/)
|
||||
})
|
||||
|
||||
it("accepts legacy hashes for indented lines", () => {
|
||||
//#given
|
||||
const lines = [" function hello() {", " return 42", " }"]
|
||||
const legacyHash = computeLegacyLineHash(1, lines[0])
|
||||
|
||||
//#when / #then
|
||||
expect(() => validateLineRef(lines, `1#${legacyHash}`)).not.toThrow()
|
||||
})
|
||||
|
||||
it("shows >>> mismatch context in batched validation", () => {
|
||||
//#given
|
||||
const lines = ["one", "two", "three", "four"]
|
||||
|
||||
Reference in New Issue
Block a user