pi-readseek 0.4.18 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/hashline.ts +8 -3
package/package.json
CHANGED
package/src/hashline.ts
CHANGED
|
@@ -58,7 +58,7 @@ const RADIX = 16;
|
|
|
58
58
|
const HASH_MOD = RADIX ** HASH_LEN;
|
|
59
59
|
const DICT = Array.from({ length: HASH_MOD }, (_, i) => i.toString(RADIX).padStart(HASH_LEN, "0"));
|
|
60
60
|
|
|
61
|
-
const HASHLINE_PREFIX_RE =
|
|
61
|
+
const HASHLINE_PREFIX_RE = /^[\s>]*\d+:[0-9a-zA-Z]{1,16}\|/;
|
|
62
62
|
const DIFF_PLUS_RE = /^\+(?!\+)/;
|
|
63
63
|
const HASH_ONLY_PREFIX_RE = /^[0-9a-f]{3}\|/;
|
|
64
64
|
const HASH_RELOCATION_WINDOW_BASE = 20;
|
|
@@ -119,9 +119,14 @@ export function formatHashlineDisplay(lineNumber: number, content: string): stri
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export function parseLineRef(ref: string): { line: number; hash: string; content?: string } {
|
|
122
|
-
const
|
|
122
|
+
const firstLine = ref.split(/\r?\n/, 1)[0]; // an anchor is one line; ignore any pasted trailing lines
|
|
123
|
+
const contentMatch = firstLine.match(/^[^|]*\|(.*)$/);
|
|
123
124
|
const contentAfterPipe = contentMatch ? contentMatch[1] : undefined;
|
|
124
|
-
const cleaned =
|
|
125
|
+
const cleaned = firstLine
|
|
126
|
+
.replace(/\|.*$/, "") // drop |content suffix
|
|
127
|
+
.replace(/^[\s>]+/, "") // drop leading gutter: >> / >>> / indentation
|
|
128
|
+
.replace(/ {2}.*$/, "") // drop trailing " comment"
|
|
129
|
+
.trim();
|
|
125
130
|
const normalized = cleaned.replace(/\s*:\s*/, ":");
|
|
126
131
|
const match = normalized.match(new RegExp(`^(\\d+):([0-9a-fA-F]{${HASH_LEN}})$`));
|
|
127
132
|
if (!match) throw new Error(`Invalid line reference "${ref}". Expected "LINE:HASH" (e.g. "5:abc").`);
|