branch: elpa/helm
commit 56ac197f372a169101d84cf71c304221a06ceeb0
Author: Thierry Volpiatto <thie...@posteo.net>
Commit: Thierry Volpiatto <thie...@posteo.net>

    Avoid using a flag for recentering when preselecting
---
 helm-core.el | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/helm-core.el b/helm-core.el
index 410f01baf1..ea0ced5b07 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -5109,7 +5109,7 @@ without recomputing them, it should be a list of lists."
         (when preselect
           (helm-log "helm-update" "Update preselect candidate %s" preselect)
           (if (helm-window)
-              (with-helm-window (helm-preselect preselect source))
+              (with-helm-window (helm-preselect preselect source 'recenter))
             (helm-preselect preselect source)))
         (setq helm--force-updating-p nil)
         (helm--reset-update-flag))
@@ -6520,7 +6520,7 @@ This is the default function for `helm-debug-function'."
 
 ;; Misc
 
-(defun helm-preselect (candidate-or-regexp &optional source)
+(defun helm-preselect (candidate-or-regexp &optional source recenter)
   "Move selection to CANDIDATE-OR-REGEXP.
 
 CANDIDATE-OR-REGEXP can be a:
@@ -6559,7 +6559,7 @@ CANDIDATE-OR-REGEXP from there."
     (when helm-allow-mouse
       (helm--mouse-reset-selection-help-echo))
     (helm-mark-current-line)
-    (when helm--deleting-minibuffer-contents-from (recenter))
+    (when recenter (recenter))
     (helm-display-mode-line (or source (helm-get-current-source)))
     (helm-log-run-hook "helm-preselect" 'helm-after-preselection-hook)))
 
@@ -6628,14 +6628,10 @@ Used generally to modify current selection."
   `(helm--edit-current-selection-internal
     (lambda () ,@forms)))
 
-(defvar helm--deleting-minibuffer-contents-from nil
-  "[INTERNAL] Recenter when deleting minibuffer-contents and preselecting.
-This is a flag used internally.")
 (defun helm--delete-minibuffer-contents-from (from-str &optional presel)
   ;; Giving an empty string value to FROM-STR delete all.
   (let ((input (minibuffer-contents))
         (src (and presel (helm-get-current-source)))
-        (helm--deleting-minibuffer-contents-from presel)
         helm-move-to-line-cycle-in-source)
     (helm-reset-yank-point)
     (unless (zerop (length input))

Reply via email to