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