Skip to content

Commit

Permalink
Preserve idx text property in marked candidates
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
basil-conto committed Jul 27, 2021
1 parent 1642e20 commit 031d4d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 031d4d0

Please sign in to comment.