From 41f31ba9ce406c057732b9788a6d756953b9d759 Mon Sep 17 00:00:00 2001 From: theschmocker Date: Sat, 19 Aug 2023 21:00:15 -0500 Subject: [PATCH] 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 --- modules/editor/snippets/autoload/snippets.el | 31 ++++++++------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/modules/editor/snippets/autoload/snippets.el b/modules/editor/snippets/autoload/snippets.el index 539a11b80..fdbb678ed 100644 --- a/modules/editor/snippets/autoload/snippets.el +++ b/modules/editor/snippets/autoload/snippets.el @@ -45,25 +45,20 @@ 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 - (hash-table-values yas--tables) - (yas--get-snippet-tables))) + (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))) - for txt = (format "%-25s%-30s%s" - (yas--template-key tpl) - (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)) + for txt = (format "%-25s%-30s%s" + (yas--template-key tpl) + (yas--template-name tpl) + (abbreviate-file-name (yas--template-load-file tpl))) + collect + (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)