Fix false matches in 'denote-sequence-get-all-sequences-with-prefix'

Change the prefix match test from 'string-prefix-p' to an algorithm
that compares entire prefix components individually.
This commit is contained in:
Kierin Bell 2025-01-30 16:07:57 -05:00
parent 88de969826
commit c76b313352

View file

@ -380,10 +380,18 @@ With optional SEQUENCES operate on those, else use the return value of
`denote-sequence-get-all-sequences'.
A sequence is a Denote signature that conforms with `denote-sequence-p'."
(seq-filter
(lambda (string)
(string-prefix-p sequence string))
(or sequences (denote-sequence-get-all-sequences))))
(let* ((prefix (denote-sequence-split sequence))
(depth (length prefix)))
(seq-filter
(lambda (string)
(let ((value (denote-sequence-split string))
(matched 0))
(while (and value
(< matched depth)
(string-equal (pop value) (nth matched prefix)))
(setq matched (1+ matched)))
(= matched depth)))
(or sequences (denote-sequence-get-all-sequences)))))
(defun denote-sequence-get-all-sequences-with-max-depth (depth &optional sequences)
"Get sequences up to DEPTH (inclusive).