* followup #16067 --spellSuggest * enable --spellSuggest by default * fixup
This commit is contained in:
parent
5fe5f47033
commit
4d3f3513e2
4 changed files with 25 additions and 23 deletions
|
|
@ -129,3 +129,4 @@ proc initDefines*(symbols: StringTableRef) =
|
||||||
defineSymbol("nimHasJsBigIntBackend")
|
defineSymbol("nimHasJsBigIntBackend")
|
||||||
defineSymbol("nimHasWarningAsError")
|
defineSymbol("nimHasWarningAsError")
|
||||||
defineSymbol("nimHasHintAsError")
|
defineSymbol("nimHasHintAsError")
|
||||||
|
defineSymbol("nimHasSpellSuggest")
|
||||||
|
|
|
||||||
|
|
@ -382,10 +382,12 @@ template toOrderTup(a: SpellCandidate): auto =
|
||||||
proc `<`(a, b: SpellCandidate): bool =
|
proc `<`(a, b: SpellCandidate): bool =
|
||||||
a.toOrderTup < b.toOrderTup
|
a.toOrderTup < b.toOrderTup
|
||||||
|
|
||||||
|
proc mustFixSpelling(c: PContext): bool {.inline.} =
|
||||||
|
result = c.config.spellSuggestMax != 0 and c.compilesContextId == 0
|
||||||
|
# don't slowdown inside compiles()
|
||||||
|
|
||||||
proc fixSpelling(c: PContext, n: PNode, ident: PIdent, result: var string) =
|
proc fixSpelling(c: PContext, n: PNode, ident: PIdent, result: var string) =
|
||||||
## when we cannot find the identifier, suggest nearby spellings
|
## when we cannot find the identifier, suggest nearby spellings
|
||||||
if c.config.spellSuggestMax == 0: return
|
|
||||||
if c.compilesContextId > 0: return # don't slowdown inside compiles()
|
|
||||||
var list = initHeapQueue[SpellCandidate]()
|
var list = initHeapQueue[SpellCandidate]()
|
||||||
let name0 = ident.s.nimIdentNormalize
|
let name0 = ident.s.nimIdentNormalize
|
||||||
|
|
||||||
|
|
@ -458,7 +460,7 @@ proc errorUndeclaredIdentifier*(c: PContext; info: TLineInfo; name: string, extr
|
||||||
|
|
||||||
proc errorUndeclaredIdentifierHint*(c: PContext; n: PNode, ident: PIdent): PSym =
|
proc errorUndeclaredIdentifierHint*(c: PContext; n: PNode, ident: PIdent): PSym =
|
||||||
var extra = ""
|
var extra = ""
|
||||||
fixSpelling(c, n, ident, extra)
|
if c.mustFixSpelling: fixSpelling(c, n, ident, extra)
|
||||||
errorUndeclaredIdentifier(c, n.info, ident.s, extra)
|
errorUndeclaredIdentifier(c, n.info, ident.s, extra)
|
||||||
result = errorSym(c, n)
|
result = errorSym(c, n)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,23 @@ type # please make sure we have under 32 options
|
||||||
TGlobalOptions* = set[TGlobalOption]
|
TGlobalOptions* = set[TGlobalOption]
|
||||||
|
|
||||||
const
|
const
|
||||||
harmlessOptions* = {optForceFullMake, optNoLinking, optRun,
|
harmlessOptions* = {optForceFullMake, optNoLinking, optRun, optUseColors, optStdout}
|
||||||
optUseColors, optStdout}
|
genSubDir* = RelativeDir"nimcache"
|
||||||
|
NimExt* = "nim"
|
||||||
|
RodExt* = "rod"
|
||||||
|
HtmlExt* = "html"
|
||||||
|
JsonExt* = "json"
|
||||||
|
TagsExt* = "tags"
|
||||||
|
TexExt* = "tex"
|
||||||
|
IniExt* = "ini"
|
||||||
|
DefaultConfig* = RelativeFile"nim.cfg"
|
||||||
|
DefaultConfigNims* = RelativeFile"config.nims"
|
||||||
|
DocConfig* = RelativeFile"nimdoc.cfg"
|
||||||
|
DocTexConfig* = RelativeFile"nimdoc.tex.cfg"
|
||||||
|
htmldocsDir* = htmldocsDirname.RelativeDir
|
||||||
|
docRootDefault* = "@default" # using `@` instead of `$` to avoid shell quoting complications
|
||||||
|
oKeepVariableNames* = true
|
||||||
|
spellSuggestSecretSauce* = -1
|
||||||
|
|
||||||
type
|
type
|
||||||
TBackend* = enum
|
TBackend* = enum
|
||||||
|
|
@ -483,6 +498,7 @@ proc newConfigRef*(): ConfigRef =
|
||||||
suggestMaxResults: 10_000,
|
suggestMaxResults: 10_000,
|
||||||
maxLoopIterationsVM: 10_000_000,
|
maxLoopIterationsVM: 10_000_000,
|
||||||
vmProfileData: newProfileData(),
|
vmProfileData: newProfileData(),
|
||||||
|
spellSuggestMax: spellSuggestSecretSauce,
|
||||||
)
|
)
|
||||||
setTargetFromSystem(result.target)
|
setTargetFromSystem(result.target)
|
||||||
# enable colors by default on terminals
|
# enable colors by default on terminals
|
||||||
|
|
@ -560,24 +576,6 @@ template compilationCachePresent*(conf: ConfigRef): untyped =
|
||||||
template optPreserveOrigSource*(conf: ConfigRef): untyped =
|
template optPreserveOrigSource*(conf: ConfigRef): untyped =
|
||||||
optEmbedOrigSrc in conf.globalOptions
|
optEmbedOrigSrc in conf.globalOptions
|
||||||
|
|
||||||
const
|
|
||||||
genSubDir* = RelativeDir"nimcache"
|
|
||||||
NimExt* = "nim"
|
|
||||||
RodExt* = "rod"
|
|
||||||
HtmlExt* = "html"
|
|
||||||
JsonExt* = "json"
|
|
||||||
TagsExt* = "tags"
|
|
||||||
TexExt* = "tex"
|
|
||||||
IniExt* = "ini"
|
|
||||||
DefaultConfig* = RelativeFile"nim.cfg"
|
|
||||||
DefaultConfigNims* = RelativeFile"config.nims"
|
|
||||||
DocConfig* = RelativeFile"nimdoc.cfg"
|
|
||||||
DocTexConfig* = RelativeFile"nimdoc.tex.cfg"
|
|
||||||
htmldocsDir* = htmldocsDirname.RelativeDir
|
|
||||||
docRootDefault* = "@default" # using `@` instead of `$` to avoid shell quoting complications
|
|
||||||
oKeepVariableNames* = true
|
|
||||||
spellSuggestSecretSauce* = -1
|
|
||||||
|
|
||||||
proc mainCommandArg*(conf: ConfigRef): string =
|
proc mainCommandArg*(conf: ConfigRef): string =
|
||||||
## This is intended for commands like check or parse
|
## This is intended for commands like check or parse
|
||||||
## which will work on the main project file unless
|
## which will work on the main project file unless
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ switch("path", "$lib/../testament/lib")
|
||||||
switch("colors", "off")
|
switch("colors", "off")
|
||||||
switch("listFullPaths", "off")
|
switch("listFullPaths", "off")
|
||||||
switch("excessiveStackTrace", "off")
|
switch("excessiveStackTrace", "off")
|
||||||
|
switch("spellSuggest", "0")
|
||||||
|
|
||||||
# for std/unittest
|
# for std/unittest
|
||||||
switch("define", "nimUnittestOutputLevel:PRINT_FAILURES")
|
switch("define", "nimUnittestOutputLevel:PRINT_FAILURES")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue