From: Daniel Carl <danielcarl@gmx.de>
Date: Thu, 19 Dec 2013 18:10:09 +0000 (+0100)
Subject: Keep active hint focused if it's still valid (#53).
X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=aa5653d111a45bf8eb8748221cf530e3b1c13c0f;p=vimb.git

Keep active hint focused if it's still valid (#53).

If a hint is focussed and later filter will keep it valid, the hint also keeps
focussed.
---

diff --git a/src/hints.js b/src/hints.js
index 0730c6b..590163e 100644
--- a/src/hints.js
+++ b/src/hints.js
@@ -231,7 +231,7 @@ var VbHint = (function(){
     }
 
     function show() {
-        var i, hint,
+        var i, hint, newIdx,
             num     = 1,
             matcher = getMatcher(filterText);
 
@@ -261,7 +261,11 @@ var VbHint = (function(){
 
             return fire();
         }
-        return focusHint(0);
+
+        /* if the previous active hint isn't valid set focus to first */
+        if (!activeHint || validHints.indexOf(activeHint) < 0) {
+            return focusHint(0);
+        }
     }
 
     /* Returns a validator method to check if the hint elements text matches */