diff options
| author | Vineet Kumar <git@vineetk.net> | 2026-05-26 02:39:12 -0400 |
|---|---|---|
| committer | Vineet Kumar <git@vineetk.net> | 2026-05-26 03:21:07 -0400 |
| commit | 5f58df0ee61c74c329a081cff56f48cb89541da5 (patch) | |
| tree | 2b51bff78f9da5b992d849a4761d3ca32f16bcd8 /llm-tools-hl-test.el | |
| parent | 4e2c04ec27a7e69272dcede8efaa7fc2d36898cf (diff) | |
fix anchor extraction and operation parsing to handle payload lines
- avoid processing payload and comment lines via filter.
- add guard on short strings (2 and under) just in case.
- fixed args-out-of-range crash when payload lines appeared in patches.
Diffstat (limited to 'llm-tools-hl-test.el')
| -rw-r--r-- | llm-tools-hl-test.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llm-tools-hl-test.el b/llm-tools-hl-test.el index d008491..879a4b4 100644 --- a/llm-tools-hl-test.el +++ b/llm-tools-hl-test.el | |||
| @@ -665,3 +665,18 @@ | |||
| 665 | (let ((op (car (llm-tools--hl-parse-section section)))) | 665 | (let ((op (car (llm-tools--hl-parse-section section)))) |
| 666 | (should (eq (hl-op-type op) 'insert-before)) | 666 | (should (eq (hl-op-type op) 'insert-before)) |
| 667 | (should (string= (hl-op-anchor op) "BOF"))))) | 667 | (should (string= (hl-op-anchor op) "BOF"))))) |
| 668 | |||
| 669 | (ert-deftest llm-tools--hl-get-anchors-with-payload-lines-test () | ||
| 670 | "Test that payload lines (~) are ignored during anchor extraction. | ||
| 671 | This would have caught the args-out-of-range crash when anchor extraction | ||
| 672 | tried to parse a line like \"~payload\" as an operation." | ||
| 673 | (let ((patch "@@ test.el\n+ 4ei\n~some payload\n~another line\n= 3gv..6be\n~replacement")) | ||
| 674 | (let ((anchors (llm-tools--hl-get-anchors patch))) | ||
| 675 | (should (= (length anchors) 1)) | ||
| 676 | (let ((file-anchors (cdr (car anchors)))) | ||
| 677 | (should (member "4ei" file-anchors)) | ||
| 678 | (should (member "3gv" file-anchors)) | ||
| 679 | (should (member "6be" file-anchors)) | ||
| 680 | (should-not (member "some payload" file-anchors)) | ||
| 681 | (should-not (member "another line" file-anchors)) | ||
| 682 | (should-not (member "replacement" file-anchors)))))) | ||
