- Added `./hashline` package exports and redirected callers to the new hashline entrypoint. - Moved hashline logic out of `edit/` to `src/hashline` and removed `edit/modes/hashline`/`edit/line-hash` paths. - Added hashline parsers, anchors, types, and diff helpers with stricter input and mismatch validation. - Implemented preflight and cache-recovery execution flows to reapply edits and handle stale anchor mismatches. - Documented the hashline API relocation as breaking changes in `CHANGELOG.md`.
23 lines
758 B
TypeScript
23 lines
758 B
TypeScript
import { computeLineHash } from "../hashline/hash";
|
|
|
|
/**
|
|
* Format a single line of match output for grep/ast-grep style results.
|
|
*
|
|
* The anchor/content separator is always `|`. Matched lines are prefixed
|
|
* with `*`; context lines are prefixed with a single space so anchors
|
|
* align in column. In hashline mode the anchor is `LINE+ID` (no `#`); in
|
|
* plain mode it is just the line number. Line numbers are never padded.
|
|
*/
|
|
export function formatMatchLine(
|
|
lineNumber: number,
|
|
line: string,
|
|
isMatch: boolean,
|
|
options: { useHashLines: boolean },
|
|
): string {
|
|
const marker = isMatch ? "*" : " ";
|
|
if (options.useHashLines) {
|
|
return `${marker}${lineNumber}${computeLineHash(lineNumber, line)}|${line}`;
|
|
}
|
|
return `${marker}${lineNumber}|${line}`;
|
|
}
|