suggest: quote operators and keywords on suggestion (#10460)

This commit is contained in:
alaviss
2019-01-28 15:29:49 +07:00
committed by Andreas Rumpf
parent 690f21043d
commit 74a7b09412
2 changed files with 16 additions and 2 deletions

View File

@@ -33,7 +33,7 @@
# included from sigmatch.nim
import algorithm, prefixmatches, lineinfos, pathutils
from wordrecg import wDeprecated, wError
from wordrecg import wDeprecated, wError, wAddr, wYield, specialWords
when defined(nimsuggest):
import passes, tables # importer
@@ -109,7 +109,11 @@ proc symToSuggest(conf: ConfigRef; s: PSym, isLocal: bool, section: IdeCmd, info
result.qualifiedPath.add(ow2.origModuleName)
if ow != nil:
result.qualifiedPath.add(ow.origModuleName)
result.qualifiedPath.add(s.name.s)
if s.name.s[0] in OpChars + {'[', '{', '('} or
s.name.id in ord(wAddr)..ord(wYield):
result.qualifiedPath.add('`' & s.name.s & '`')
else:
result.qualifiedPath.add(s.name.s)
if s.typ != nil:
result.forth = typeToString(s.typ)

View File

@@ -0,0 +1,10 @@
proc `%%%`(a: int) = discard
proc `cast`() = discard
tsug_accquote.#[!]#
discard """
$nimsuggest --tester $file
>sug $1
sug;;skProc;;tsug_accquote.`%%%`;;proc (a: int);;$file;;1;;5;;"";;100;;None
sug;;skProc;;tsug_accquote.`cast`;;proc ();;$file;;2;;5;;"";;100;;None
"""