fix(snippets): fix snippet uuid completion

Rather than attempting to read the uuid from a text property on the
selected completion -- which gets stripped by vertico (and possibly
helm) -- grab it from a lookup alist of completion-candidat->uuid.

Essentially the same as the proposed implementation by @jgrey4296
on #4127

Fix: #4127
This commit is contained in:
theschmocker 2023-08-19 21:00:15 -05:00
parent 5155f4aa78
commit 41f31ba9ce

View file

@ -45,10 +45,9 @@ Finds correctly active snippets from parent modes (based on Yas' logic)."
return it))
(defun +snippet--completing-read-uuid (prompt all-snippets &rest args)
(plist-get
(text-properties-at
0 (apply #'completing-read prompt
(cl-loop for (_ . tpl) in (mapcan #'yas--table-templates (if all-snippets
(let* ((completion-uuid-alist
(cl-loop for (_ . tpl) in (mapcan #'yas--table-templates
(if all-snippets
(hash-table-values yas--tables)
(yas--get-snippet-tables)))
@ -57,13 +56,9 @@ Finds correctly active snippets from parent modes (based on Yas' logic)."
(yas--template-name tpl)
(abbreviate-file-name (yas--template-load-file tpl)))
collect
(progn
(set-text-properties 0 (length txt) `(uuid ,(yas--template-uuid tpl)
path ,(yas--template-load-file tpl))
txt)
txt))
args))
'uuid))
(cons txt (yas--template-uuid tpl))))
(completion (apply #'completing-read prompt completion-uuid-alist args)))
(alist-get completion completion-uuid-alist nil nil #'string=)))
(defun +snippet--abort ()
(interactive)