From dd951e98d042c4d389878a39748fb03384aff783 Mon Sep 17 00:00:00 2001 From: Rik van der Kleij Date: Sun, 3 Nov 2019 13:41:07 +0100 Subject: [PATCH] Be sure ":browse Prelude" always has qualified identifiers --- .../haskell/external/repl/StackRepl.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/scala/intellij/haskell/external/repl/StackRepl.scala b/src/main/scala/intellij/haskell/external/repl/StackRepl.scala index e4e75ebd..88dff5fc 100644 --- a/src/main/scala/intellij/haskell/external/repl/StackRepl.scala +++ b/src/main/scala/intellij/haskell/external/repl/StackRepl.scala @@ -85,6 +85,8 @@ abstract class StackRepl(project: Project, componentInfo: Option[StackComponentI def getComponentName: String = componentInfo.map(_.target).map(t => "project-stack-repl-" + t).getOrElse("global-stack-repl") + def isGlobalRepl: Boolean = componentInfo.isEmpty + private val stdoutResult = new ArrayBuffer[String] private val stderrResult = new ArrayBuffer[String] @@ -315,7 +317,12 @@ abstract class StackRepl(project: Project, componentInfo: Option[StackComponentI } private def createGhciOptionsFile: File = { - val ghciOptionsFile = new File(GlobalInfo.getIntelliJHaskellDirectory, "repl.ghci") + val ghciOptionsFile = if (isGlobalRepl) { + new File(GlobalInfo.getIntelliJHaskellDirectory, "global-repl.ghci") + } else { + new File(GlobalInfo.getIntelliJHaskellDirectory, "repl.ghci") + } + if (!ghciOptionsFile.exists()) { ghciOptionsFile.createNewFile() ghciOptionsFile.setWritable(true, true) @@ -324,6 +331,12 @@ abstract class StackRepl(project: Project, componentInfo: Option[StackComponentI val writer = new BufferedWriter(new FileWriter(ghciOptionsFile)) try { writer.write(s""":set prompt "$EndOfOutputIndicator\\n"""") + if (isGlobalRepl) { + writer.write("\n") + writer.write(s""":set -XNoImplicitPrelude""") + writer.write("\n") + writer.write(":l") // Force Prelude is not loaded because for :browse qualified identifiers are needed + } } finally { writer.close() }