diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-08-27 10:03:34 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-08-27 10:03:34 +0200 |
commit | fe1acfcf69e612f411a094d2536affbc8252a5ed (patch) | |
tree | 61d960059cfe73f920919dfae91faf60b8e14ea2 /helm-dabbrev.el | |
parent | ec985d97df3b8bcea13d37b0a8dc3201fba8ecef (diff) |
Fix limit in helm-dabbrev--collect
* helm-dabbrev.el (helm-dabbrev--collect): Break when reaching limit
and avoid collecting nil candidates.
Diffstat (limited to 'helm-dabbrev.el')
-rw-r--r-- | helm-dabbrev.el | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/helm-dabbrev.el b/helm-dabbrev.el index a55614d5..5e42fccf 100644 --- a/helm-dabbrev.el +++ b/helm-dabbrev.el @@ -141,29 +141,30 @@ but the initial search for all candidates in buffer(s)." result pos-before pos-after (search-and-store (lambda (pattern direction) - (while (cl-case direction - (1 (search-forward pattern nil t)) - (-1 (search-backward pattern nil t)) - (2 (let ((pos - (save-excursion - (forward-line - helm-dabbrev-lineno-around) - (point)))) - (setq pos-after pos) - (search-forward pattern pos t))) - (-2 (let ((pos - (save-excursion - (forward-line - (- helm-dabbrev-lineno-around)) - (point)))) - (setq pos-before pos) - (search-backward pattern pos t)))) + (while (and (<= (length result) limit) + (cl-case direction + (1 (search-forward pattern nil t)) + (-1 (search-backward pattern nil t)) + (2 (let ((pos + (save-excursion + (forward-line + helm-dabbrev-lineno-around) + (point)))) + (setq pos-after pos) + (search-forward pattern pos t))) + (-2 (let ((pos + (save-excursion + (forward-line + (- helm-dabbrev-lineno-around)) + (point)))) + (setq pos-before pos) + (search-backward pattern pos t))))) (let* ((pbeg (match-beginning 0)) (replace-regexp (concat "\\(" helm-dabbrev-separator-regexp "\\)\\'")) (match-word (helm-dabbrev--search pattern pbeg replace-regexp))) - (unless (member match-word result) + (when (and match-word (not (member match-word result))) (push match-word result))))))) (cl-loop for buf in (if all (helm-dabbrev--buffer-list) (list (current-buffer))) @@ -188,7 +189,7 @@ but the initial search for all candidates in buffer(s)." ;; Search all after point. (goto-char pos-after) ; start from [2] (funcall search-and-store str 1)))) - when (> (length result) limit) return (nreverse result) + when (>= (length result) limit) return (nreverse result) finally return (nreverse result)))) (defun helm-dabbrev--search (pattern beg sep-regexp) |