From 204136e66ccc5a9675178987a5d34e9fd95ba174 Mon Sep 17 00:00:00 2001 From: Vineet Kumar Date: Sun, 24 May 2026 17:24:13 -0400 Subject: 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. --- llm-tools-hl.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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. Precisely: https://raw.githubusercontent.com/can1357/oh-my-pi/85003ca/packages/coding-agent/src/hashline/bigrams.json") (defun llm-tools--hl-hash (line) - (elt llm-tools--hl-bigrams (% (sxhash line) 647))) + ;; logand is to force unsigned number + (elt llm-tools--hl-bigrams (% (logand (sxhash line) #xffffffff) 647))) (defun llm-tools--hl-file-lines (file &optional beg end) "Return FILE contents as a list of strings. -- cgit v1.2.3