summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authoralaviss <alaviss@users.noreply.github.com>2020-04-20 09:54:53 +0000
committerGitHub <noreply@github.com>2020-04-20 11:54:53 +0200
commit77834f0fdabc9d39cf111c4c94e717bd2c4f00d2 (patch)
tree4ba31de3ccbd33ae29290c1eb3b7d83f4498ed16 /compiler
parente6cf11351d10e38ec58faeb3cb0a134f616a2ba3 (diff)
downloadNim-77834f0fdabc9d39cf111c4c94e717bd2c4f00d2.tar.gz
compiler/suggest: highlight squashed operators (#11796)
The operator fetching proc is greedy, so operators such as `%*` in
expression `%*{}` can't be highlighted.

This commit fixes that.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/suggest.nim10
1 files changed, 7 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;