summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-04-21 21:36:18 +0800
committerGitHub <noreply@github.com>2023-04-21 15:36:18 +0200
commitb54b03d04fc19d18e079ee759730298e2ecd63fd (patch)
treef0d4507eae539611a425cfc3298f910b51e270bc /compiler
parent175a83c2de436b0e84f232fd44d264fb2c79fb14 (diff)
downloadNim-b54b03d04fc19d18e079ee759730298e2ecd63fd.tar.gz
tweak spellsuggest; three counts for equal distances candidates by default (#21700)
* tweak spellsuggest; three counts for equal distances candidates

* only suggest typos when length > 3
Diffstat (limited to 'compiler')
-rw-r--r--compiler/lookups.nim9
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/lookups.nim b/compiler/lookups.nim
index fc84b9051..8b98ea3f1 100644
--- a/compiler/lookups.nim
+++ b/compiler/lookups.nim
@@ -490,12 +490,9 @@ proc fixSpelling(c: PContext, n: PNode, ident: PIdent, result: var string) =
     let e = list.pop()
     if c.config.spellSuggestMax == spellSuggestSecretSauce:
       const
-        smallThres = 2
-        maxCountForSmall = 4
-        # avoids ton of operator matches when mis-matching short symbols such as `i`
-        # other heuristics could be devised, such as only suggesting operators if `name0`
-        # is an operator (likewise with non-operators).
-      if e.dist > e0.dist or (name0.len <= smallThres and count >= maxCountForSmall): break
+        minLengthForSuggestion = 4
+        maxCount = 3 # avoids ton of matches; three counts for equal distances
+      if e.dist > e0.dist or count >= maxCount or name0.len < minLengthForSuggestion: break
     elif count >= c.config.spellSuggestMax: break
     if count == 0:
       result.add "\ncandidates (edit distance, scope distance); see '--spellSuggest': "