branch: externals/company
commit cb4d0df12909c8b1ba82ae6eda43b230623e5bc0
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>

    If search fails in the natural direction, try searching back
---
 company.el | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/company.el b/company.el
index 62596a0c2b..a0d04f4c8b 100644
--- a/company.el
+++ b/company.el
@@ -2868,9 +2868,16 @@ each one wraps a part of the input string."
   (let* ((selection (or company-selection 0))
          (pos (company--search new (nthcdr selection company-candidates))))
     (if (null pos)
+        (let ((pos (company--search new (nthcdr (- company-candidates-length
+                                                   selection)
+                                                (reverse 
company-candidates)))))
+          (if (null pos)
+              (ding)
+            (setq company-search-string new)
+            (company-set-selection (- selection pos 1) t)))
         (ding)
-      (setq company-search-string new)
-      (company-set-selection (+ selection pos) t))))
+        (setq company-search-string new)
+        (company-set-selection (+ selection pos) t))))
 
 (defun company--search-assert-input ()
   (company--search-assert-enabled)
@@ -2883,7 +2890,7 @@ each one wraps a part of the input string."
   (company--search-assert-input)
   (let* ((selection (or company-selection 0))
          (pos (company--search company-search-string
-                              (cdr (nthcdr selection company-candidates)))))
+                               (cdr (nthcdr selection company-candidates)))))
     (if (null pos)
         (ding)
       (company-set-selection (+ selection pos 1) t))))

Reply via email to