From 031d4d051da1d8fd20f0f46e8df66c426bf3174c Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Tue, 27 Jul 2021 20:07:04 +0100 Subject: [PATCH] Preserve idx text property in marked candidates Both internal and external code expects the idx property to be on the first character of the candidate. Since ivy--mark actually makes the mark a part of the candidate, it should also preserve any text properties at the start of the candidate. * ivy.el (ivy--mark): Copy any text properties from the start of the candidate to the mark prefix. Consistently use destructive operations on ivy-marked-candidates. --- ivy.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ivy.el b/ivy.el index 908f3995..659ba3e2 100644 --- a/ivy.el +++ b/ivy.el @@ -5238,11 +5238,16 @@ EVENT gives the mouse position." (delete cand ivy-marked-candidates))) (defun ivy--mark (cand) - (let ((marked-cand (concat ivy-mark-prefix cand))) + (let ((marked-cand (copy-sequence (concat ivy-mark-prefix cand)))) + ;; Primarily for preserving `idx'. FIXME: the mark + ;; prefix shouldn't become part of the candidate! + (add-text-properties 0 (length ivy-mark-prefix) + (text-properties-at 0 cand) + marked-cand) (setcar (member cand ivy--all-candidates) (setcar (member cand ivy--old-cands) marked-cand)) (setq ivy-marked-candidates - (append ivy-marked-candidates (list marked-cand))))) + (nconc ivy-marked-candidates (list marked-cand))))) (defun ivy-mark () "Mark the selected candidate and move to the next one.