summaryrefslogtreecommitdiff
path: root/compiler/utils/Util.lhs
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2011-01-07 10:28:55 +0000
committersimonpj@microsoft.com <unknown>2011-01-07 10:28:55 +0000
commiteaf9bfda24eccd4ca4169cb7fa0fc9c7692e418c (patch)
tree4967a94598e0d4df37f5438c9c8b773c35d247a3 /compiler/utils/Util.lhs
parent0aebf9c6b0de711b7eefa8c4cdd56d9328886697 (diff)
downloadhaskell-eaf9bfda24eccd4ca4169cb7fa0fc9c7692e418c.tar.gz
Make fuzzy matching a little less eager for short identifiers
For single-character identifiers we now don't make any suggestions See comments in Util.fuzzyLookup
Diffstat (limited to 'compiler/utils/Util.lhs')
-rw-r--r--compiler/utils/Util.lhs15
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs
index b08f6fab57..6b17a2821e 100644
--- a/compiler/utils/Util.lhs
+++ b/compiler/utils/Util.lhs
@@ -801,9 +801,18 @@ fuzzyLookup user_entered possibilites
poss_str user_entered
, distance <= fuzzy_threshold ]
where
- -- Work out an approriate match threshold
- -- (about a quarter of the # of characters the user entered)
- fuzzy_threshold = max (round $ fromInteger (genericLength user_entered) / (4 :: Rational)) 1
+ -- Work out an approriate match threshold:
+ -- We report a candidate if its edit distance is <= the threshold,
+ -- The threshhold is set to about a quarter of the # of characters the user entered
+ -- Length Threshold
+ -- 1 0 -- Don't suggest *any* candidates
+ -- 2 1 -- for single-char identifiers
+ -- 3 1
+ -- 4 1
+ -- 5 1
+ -- 6 2
+ --
+ fuzzy_threshold = truncate $ fromIntegral (length user_entered + 2) / (4 :: Rational)
mAX_RESULTS = 3
\end{code}