summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorIvan Yonchovski <yyoncho@users.noreply.github.com>2022-07-15 20:56:33 +0300
committerGitHub <noreply@github.com>2022-07-15 19:56:33 +0200
commitb0b9a3e5fade002b8f117f7ffb4d8fb93686401d (patch)
treee21ddca051aa055739dcfb07deefdcddd76ebdc6
parente636c211b0815497bc83a07424a06b03439119cd (diff)
downloadNim-b0b9a3e5fade002b8f117f7ffb4d8fb93686401d.tar.gz
Use module actual file instead of PSym.info (#19956)
After this you can do goto module from module import
-rw-r--r--compiler/suggest.nim30
-rw-r--r--nimsuggest/tests/tv3_import.nim7
2 files changed, 25 insertions, 12 deletions
diff --git a/compiler/suggest.nim b/compiler/suggest.nim
index 4b48ef5bb..7e7d876fb 100644
--- a/compiler/suggest.nim
+++ b/compiler/suggest.nim
@@ -157,19 +157,25 @@ proc symToSuggest*(g: ModuleGraph; s: PSym, isLocal: bool, section: IdeCmd, info
       result.forth = ""
     when defined(nimsuggest) and not defined(noDocgen) and not defined(leanCompiler):
       result.doc = extractDocComment(g, s)
-  let infox =
-    if useSuppliedInfo or section in {ideUse, ideHighlight, ideOutline}:
-      info
-    else:
-      s.info
-  result.filePath = toFullPath(g.config, infox)
-  result.line = toLinenumber(infox)
-  result.column = toColumn(infox)
+  if s.kind == skModule and s.ast.len != 0 and section != ideHighlight:
+    result.filePath = toFullPath(g.config, s.ast[0].info)
+    result.line = 1
+    result.column = 0
+    result.tokenLen = 0
+  else:
+    let infox =
+      if useSuppliedInfo or section in {ideUse, ideHighlight, ideOutline}:
+        info
+      else:
+        s.info
+    result.filePath = toFullPath(g.config, infox)
+    result.line = toLinenumber(infox)
+    result.column = toColumn(infox)
+    result.tokenLen = if section != ideHighlight:
+                        s.name.s.len
+                      else:
+                        getTokenLenFromSource(g.config, s.name.s, infox)
   result.version = g.config.suggestVersion
-  result.tokenLen = if section != ideHighlight:
-                      s.name.s.len
-                    else:
-                      getTokenLenFromSource(g.config, s.name.s, infox)
 
 proc `$`*(suggest: Suggest): string =
   result = $suggest.section
diff --git a/nimsuggest/tests/tv3_import.nim b/nimsuggest/tests/tv3_import.nim
new file mode 100644
index 000000000..3c128f85b
--- /dev/null
+++ b/nimsuggest/tests/tv3_import.nim
@@ -0,0 +1,7 @@
+import tv#[!]#3
+
+discard """
+$nimsuggest --v3 --tester $file
+>def $1
+def	skModule	tv3		*/tv3.nim	1	0	""	100
+"""