diff --git a/compiler/modules/modulegraphs.nim b/compiler/modules/modulegraphs.nim index 95226f44a6c..23e06e0c67e 100644 --- a/compiler/modules/modulegraphs.nim +++ b/compiler/modules/modulegraphs.nim @@ -599,7 +599,7 @@ proc parentModule*(g: ModuleGraph; fileIdx: FileIndex): FileIndex = if fileIdx.int32 >= 0 and fileIdx.int32 < g.ifaces.len and g.ifaces[fileIdx.int32].module != nil: result = fileIdx else: - result = g.inclToMod.getOrDefault(fileIdx) + result = g.inclToMod.getOrDefault(fileIdx, InvalidFileIdx) proc markDirty*(g: ModuleGraph; fileIdx: FileIndex) = let m = g.getModule fileIdx diff --git a/compiler/tools/suggest.nim b/compiler/tools/suggest.nim index 3c097ae60cf..f18588b12e9 100644 --- a/compiler/tools/suggest.nim +++ b/compiler/tools/suggest.nim @@ -492,7 +492,9 @@ proc executeCmd*(cmd: IdeCmd, file, dirtyfile: AbsoluteFile, line, col: int; dirtyfile.isEmpty: discard "no need to recompile anything" else: - let modIdx = graph.parentModule(dirtyIdx) + var modIdx = graph.parentModule(dirtyIdx) + if modIdx == InvalidFileIdx: + modIdx = dirtyIdx graph.markDirty dirtyIdx graph.markClientsDirty dirtyIdx # partially recompiling the project means that that VM and JIT state