@oh-my-pi/hashline 15.8.3 → 15.9.1
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/grammar.lark +4 -3
- package/src/parser.ts +4 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/hashline",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.9.1",
|
|
5
5
|
"description": "Hashline: a compact, line-anchored patch language and applier. Pluggable FS/IO so it works over disk, in-memory, or any custom backend.",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
package/src/grammar.lark
CHANGED
|
@@ -7,11 +7,12 @@ file_header: "¶" filename "#" file_hash LF
|
|
|
7
7
|
file_hash: /[0-9A-F]{4}/
|
|
8
8
|
filename: /[^\s#]+/
|
|
9
9
|
|
|
10
|
-
hunk:
|
|
11
|
-
|
|
10
|
+
hunk: replace_hunk | replace_block_hunk | insert_hunk | delete_hunk | delete_block_hunk
|
|
11
|
+
replace_hunk: replace_anchor LF emit_op*
|
|
12
|
+
replace_block_hunk: replace_block_anchor LF emit_op+
|
|
13
|
+
insert_hunk: insert_anchor LF emit_op+
|
|
12
14
|
delete_hunk: "delete " header_range LF
|
|
13
15
|
delete_block_hunk: "delete block " LID LF
|
|
14
|
-
body_header: (replace_anchor | replace_block_anchor | insert_anchor) LF
|
|
15
16
|
replace_anchor: "replace " header_range ":"
|
|
16
17
|
replace_block_anchor: "replace block " LID ":"
|
|
17
18
|
insert_anchor: "insert " insert_pos ":"
|
package/src/parser.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
DELETE_TAKES_NO_BODY,
|
|
11
11
|
EMPTY_BLOCK,
|
|
12
12
|
EMPTY_INSERT,
|
|
13
|
-
EMPTY_REPLACE,
|
|
14
13
|
MINUS_ROW_REJECTED,
|
|
15
14
|
} from "./messages";
|
|
16
15
|
import { type BlockTarget, cloneCursor, type ParsedRange, type Token, Tokenizer } from "./tokenizer";
|
|
@@ -280,7 +279,10 @@ export class Executor {
|
|
|
280
279
|
return;
|
|
281
280
|
}
|
|
282
281
|
if (payloads.length === 0) {
|
|
283
|
-
if (target.kind === "replace")
|
|
282
|
+
if (target.kind === "replace") {
|
|
283
|
+
for (const anchor of expandRange(target.range)) this.#pushDelete(anchor, lineNum);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
284
286
|
throw new Error(`line ${lineNum}: ${EMPTY_INSERT}`);
|
|
285
287
|
}
|
|
286
288
|
if (target.kind === "replace") {
|