diff options
| author | Vineet Kumar <git@vineetk.net> | 2026-05-24 17:24:13 -0400 |
|---|---|---|
| committer | Vineet Kumar <git@vineetk.net> | 2026-05-24 17:24:13 -0400 |
| commit | 204136e66ccc5a9675178987a5d34e9fd95ba174 (patch) | |
| tree | 47e2ecd32da401714cc4273086ee0603b23a49bf /llm-tools-hl.el | |
| parent | 1d1102a024912b2d87e711cfd746eea156865af5 (diff) | |
fix bug with negative indices in hashline computation
sxhash return type in elisp is signed instead of unsigned. this can
result in negative indices, which in elt seems to get interpreted as 0
(the "aa" bigram) resulting in same hashes for different content lines.
Diffstat (limited to 'llm-tools-hl.el')
| -rw-r--r-- | llm-tools-hl.el | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llm-tools-hl.el b/llm-tools-hl.el index 4bf3a6e..5a984e8 100644 --- a/llm-tools-hl.el +++ b/llm-tools-hl.el | |||
| @@ -55,7 +55,8 @@ Taken from https://github.com/can1357/oh-my-pi. | |||
| 55 | Precisely: https://raw.githubusercontent.com/can1357/oh-my-pi/85003ca/packages/coding-agent/src/hashline/bigrams.json") | 55 | Precisely: https://raw.githubusercontent.com/can1357/oh-my-pi/85003ca/packages/coding-agent/src/hashline/bigrams.json") |
| 56 | 56 | ||
| 57 | (defun llm-tools--hl-hash (line) | 57 | (defun llm-tools--hl-hash (line) |
| 58 | (elt llm-tools--hl-bigrams (% (sxhash line) 647))) | 58 | ;; logand is to force unsigned number |
| 59 | (elt llm-tools--hl-bigrams (% (logand (sxhash line) #xffffffff) 647))) | ||
| 59 | 60 | ||
| 60 | (defun llm-tools--hl-file-lines (file &optional beg end) | 61 | (defun llm-tools--hl-file-lines (file &optional beg end) |
| 61 | "Return FILE contents as a list of strings. | 62 | "Return FILE contents as a list of strings. |
