aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-06-10 16:14:38 +0100
committerStephen Blott2015-06-10 16:14:38 +0100
commite516bae3a3374780d2cb1b6c32e5fd1f2c13a408 (patch)
tree5029cab524f30ab3e6019ae37e247f871c5b71b8
parent9b07fa7861620900e0d1da5829b38ddb4e8ff789 (diff)
downloadvimium-e516bae3a3374780d2cb1b6c32e5fd1f2c13a408.tar.bz2
Fix incorrect filtering.
-rw-r--r--content_scripts/link_hints.coffee9
1 files changed, 7 insertions, 2 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index cbb4085e..144400b6 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -564,9 +564,15 @@ class FilterHints
# Filter link hints by search string, renumbering the hints as necessary.
filterLinkHints: (hintMarkers) ->
idx = 0
- linkSearchString = @linkTextKeystrokeQueue.join("").toLowerCase()
+ linkSearchString = @linkTextKeystrokeQueue.join("").trim().toLowerCase()
+ return hintMarkers unless 0 < linkSearchString.length
+
do (scoreFunction = @scoreLinkHint linkSearchString) ->
linkMarker.score = scoreFunction linkMarker for linkMarker in hintMarkers
+ # The Javascript sort() method is known not to be stable. Nevertheless, we require (and assume, here)
+ # that it is deterministic. So, if the user is typing hint characters, then hints will always end up in
+ # the same order and hence with the same hint strings (because hint-string filtering happens after the
+ # filtering here).
hintMarkers = hintMarkers[..].sort (a,b) -> b.score - a.score
for linkMarker in hintMarkers
@@ -577,7 +583,6 @@ class FilterHints
# Assign a score to a filter match (higher is better). We assign a higher score for matches at the start of
# a word, and a considerably higher score still for matches which are whole words.
- # Note(smblott) if linkSearchString is empty, then every hint get a score of 4.
scoreLinkHint: (linkSearchString) ->
searchWords = linkSearchString.trim().split /\s+/
(linkMarker) ->