Skip to content

Commit

Permalink
Don't loose properties in completion-in-region (#2265)
Browse files Browse the repository at this point in the history
* helm-mode.el (helm-completion-in-region-selection): New.
(helm--completion-in-region): Use it in helm-before-action-hook.
  • Loading branch information
Thierry Volpiatto committed Jan 22, 2020
1 parent 203dbe8 commit 8ed26cb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion helm-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,10 @@ that is non-nil."
(all (completion-pcm--all-completions prefix pattern table pred)))
(list all pattern prefix suffix (car bounds))))

(defun helm-completion-in-region-selection ()
(with-helm-buffer
(setq helm-saved-selection (helm-get-selection nil 'withprop))))

;; Completion-in-region-function

(defun helm--completion-in-region (origfun start end collection &optional predicate)
Expand All @@ -1679,6 +1683,7 @@ Can be used for `completion-in-region-function' by advicing it with an
(helm-aif (cdr (assq major-mode helm-completion-styles-alist))
(customize-set-variable 'helm-completion-style
(if (cdr-safe it) (car it) it)))
(add-hook 'helm-before-action-hook 'helm-completion-in-region-selection)
(unwind-protect
(let* ((enable-recursive-minibuffers t)
(completion-flex-nospace t)
Expand Down Expand Up @@ -1818,8 +1823,13 @@ Can be used for `completion-in-region-function' by advicing it with an
(message "[No matches]")))
t) ; exit minibuffer immediately.
:must-match require-match))))
(setq string result)
;; `helm-completion-in-region--insert-result' is stripping
;; out properties on RESULT and by side-effect (perhaps
;; `choose-completion-string'?) modify STRING so make a copy.
(setq string (copy-sequence result))
(remove-hook 'helm-before-action-hook 'helm-completion-in-region-selection)
(helm-completion-in-region--insert-result result start point end base-size))
;; Allow running extra property :exit-function (Issue #2265)
(completion--done string 'finished)
(customize-set-variable 'helm-completion-style old--helm-completion-style)
(setq helm-completion--sorting-done nil)
Expand Down

0 comments on commit 8ed26cb

Please sign in to comment.