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:
YeonGyu-Kim
2026-03-14 13:42:17 +09:00
parent f03de4f8a8
commit bbd2e86499
4 changed files with 43 additions and 11 deletions
@@ -1,6 +1,7 @@
import { describe, it, expect } from "bun:test"
import {
computeLineHash,
computeLegacyLineHash,
formatHashLine,
formatHashLines,
streamHashLinesFromLines,
@@ -58,6 +59,19 @@ describe("computeLineHash", () => {
expect(hash1).not.toBe(hash2)
})
it("preserves legacy hashes for leading indentation variants", () => {
//#given
const content1 = "function hello() {"
const content2 = " function hello() {"
//#when
const hash1 = computeLegacyLineHash(1, content1)
const hash2 = computeLegacyLineHash(1, content2)
//#then
expect(hash1).toBe(hash2)
})
it("ignores trailing whitespace differences", () => {
//#given
const content1 = "function hello() {"