aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-02-21 16:19:43 +0000
committerStephen Blott2016-02-21 16:19:43 +0000
commit5cbc5ad702a01a81b98f8c82edb3b6d227c2c7b5 (patch)
tree7cc618f83334d50419e6e12fe3caeffd92f53b8b
parent1de41f55c121192556a7bf182211fb3b6deeccc8 (diff)
downloadvimium-5cbc5ad702a01a81b98f8c82edb3b6d227c2c7b5.tar.bz2
Fix divide by zero.
If text.length is 1, here, then we divide by `log 1` - which is zero. So add one.
-rw-r--r--content_scripts/link_hints.coffee2
1 files changed, 1 insertions, 1 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 699c911a..8d75ed32 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -637,7 +637,7 @@ class FilterHints
score = searchWordScores.reduce addFunc, 0
# Prefer matches in shorter texts. To keep things balanced for links without any text, we just weight
# them as if their length was 50.
- score / Math.log(text.length || 50)
+ score / Math.log 1 + (text.length || 50)
#
# Make each hint character a span, so that we can highlight the typed characters as you type them.