From 9aef060e3b0869edb0b9b477097a5cb575bf92d2 Mon Sep 17 00:00:00 2001 From: Neeraj Jaiswal Date: Sat, 13 Oct 2018 14:55:52 +0530 Subject: [PATCH] Save REPL history to file .dotty_history in home directory --- compiler/src/dotty/tools/repl/JLineTerminal.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/repl/JLineTerminal.scala b/compiler/src/dotty/tools/repl/JLineTerminal.scala index 5948581e1438..3ce20d4da76a 100644 --- a/compiler/src/dotty/tools/repl/JLineTerminal.scala +++ b/compiler/src/dotty/tools/repl/JLineTerminal.scala @@ -47,12 +47,15 @@ final class JLineTerminal(needsTerminal: Boolean) extends java.io.Closeable { )(implicit ctx: Context): String = { import LineReader.Option._ import LineReader._ - val lineReader = LineReaderBuilder.builder() + val userHome = System.getProperty("user.home") + val lineReader = LineReaderBuilder + .builder() .terminal(terminal) .history(history) .completer(completer) .highlighter(new Highlighter) .parser(new Parser) + .variable(HISTORY_FILE, s"$userHome/.dotty_history") // Save history to file .variable(SECONDARY_PROMPT_PATTERN, "%M") // A short word explaining what is "missing", // this is supplied from the EOFError.getMissing() method .variable(LIST_MAX, 400) // Ask user when number of completions exceed this limit (default is 100).