diff --git a/util/complete/HistoryCommands.scala b/util/complete/HistoryCommands.scala index a5b321d8c..bbf8c0bfd 100644 --- a/util/complete/HistoryCommands.scala +++ b/util/complete/HistoryCommands.scala @@ -4,6 +4,8 @@ package sbt package complete + import java.io.File + object HistoryCommands { val Start = "!" @@ -38,7 +40,7 @@ object HistoryCommands def printHelp(): Unit = println(helpString) - def apply(s: String, historyPath: Option[Path], maxLines: Int, error: String => Unit): Option[List[String]] = + def apply(s: String, historyPath: Option[File], maxLines: Int, error: String => Unit): Option[List[String]] = if(s.isEmpty) { printHelp() @@ -46,7 +48,7 @@ object HistoryCommands } else { - val lines = historyPath.toList.flatMap(h => IO.readLines(h.asFile) ).toArray + val lines = historyPath.toList.flatMap( p => IO.readLines(p) ).toArray if(lines.isEmpty) { error("No history") @@ -66,7 +68,7 @@ object HistoryCommands { val command = historyCommand(history, s) command.foreach(lines(lines.length - 1) = _) - historyPath foreach { h => IO.writeLines(h.asFile, lines) } + historyPath foreach { h => IO.writeLines(h, lines) } Some(command.toList) } } diff --git a/util/complete/LineReader.scala b/util/complete/LineReader.scala index e7c9ec67a..d586d0729 100644 --- a/util/complete/LineReader.scala +++ b/util/complete/LineReader.scala @@ -2,7 +2,10 @@ * Copyright 2008, 2009 Mark Harrah */ package sbt -import jline.{Completor, ConsoleReader} + + import jline.{Completor, ConsoleReader} + import java.io.File + abstract class JLine extends LineReader { protected[this] val reader: ConsoleReader @@ -37,10 +40,10 @@ private object JLine try { action } finally { t.enableEcho() } } - private[sbt] def initializeHistory(cr: ConsoleReader, historyPath: Option[Path]): Unit = + private[sbt] def initializeHistory(cr: ConsoleReader, historyPath: Option[File]): Unit = for(historyLocation <- historyPath) { - val historyFile = historyLocation.asFile + val historyFile = historyLocation.getAbsoluteFile ErrorHandling.wideConvert { historyFile.getParentFile.mkdirs() @@ -49,7 +52,7 @@ private object JLine history.setHistoryFile(historyFile) } } - def simple(historyPath: Option[Path]): SimpleReader = new SimpleReader(historyPath) + def simple(historyPath: Option[File]): SimpleReader = new SimpleReader(historyPath) val MaxHistorySize = 500 } @@ -57,14 +60,14 @@ trait LineReader extends NotNull { def readLine(prompt: String): Option[String] } -private[sbt] final class LazyJLineReader(historyPath: Option[Path], completor: => Completor) extends JLine +private[sbt] final class LazyJLineReader(historyPath: Option[File] /*, completor: => Completor*/) extends JLine { protected[this] val reader = { val cr = new ConsoleReader cr.setBellEnabled(false) JLine.initializeHistory(cr, historyPath) - cr.addCompletor(new LazyCompletor(completor)) +// cr.addCompletor(new LazyCompletor(completor)) cr } } @@ -75,7 +78,7 @@ private class LazyCompletor(delegate0: => Completor) extends Completor delegate.complete(buffer, cursor, candidates) } -class SimpleReader private[sbt] (historyPath: Option[Path]) extends JLine +class SimpleReader private[sbt] (historyPath: Option[File]) extends JLine { protected[this] val reader = JLine.createReader() JLine.initializeHistory(reader, historyPath)