diff options
-rw-r--r-- | compiler/suggest.nim | 10 | ||||
-rw-r--r-- | nimsuggest/tests/top_highlight.nim | 11 |
2 files changed, 18 insertions, 3 deletions
diff --git a/compiler/suggest.nim b/compiler/suggest.nim index d8da2a7a4..58b54cc03 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -106,11 +106,15 @@ proc getTokenLenFromSource(conf: ConfigRef; ident: string; info: TLineInfo): int if cmpIgnoreStyle(line[column..column + result - 1], ident) != 0: result = 0 else: - result = skipWhile(line, OpChars + {'[', '(', '{', ']', ')', '}'}, column) + var sourceIdent: string + result = parseWhile(line, sourceIdent, + OpChars + {'[', '(', '{', ']', ')', '}'}, column) if ident[^1] == '=' and ident[0] in linter.Letters: - if line[column..column + result - 1] != "=": + if sourceIdent != "=": result = 0 - elif line[column..column + result - 1] != ident: + elif sourceIdent.len > ident.len and sourceIdent[..ident.high] == ident: + result = ident.len + elif sourceIdent != ident: result = 0 proc symToSuggest(conf: ConfigRef; s: PSym, isLocal: bool, section: IdeCmd, info: TLineInfo; diff --git a/nimsuggest/tests/top_highlight.nim b/nimsuggest/tests/top_highlight.nim new file mode 100644 index 000000000..c3f6bb61d --- /dev/null +++ b/nimsuggest/tests/top_highlight.nim @@ -0,0 +1,11 @@ +import json + +%*{}#[!]# + +discard """ +$nimsuggest --tester $file +>highlight $1 +highlight;;skModule;;1;;7;;4 +highlight;;skMacro;;3;;0;;2 +highlight;;skMacro;;3;;0;;2 +""" |