Merge pull request #3876 from eed3si9n/wip/jlineinit

Fix tab completion running `sbt console`
This commit is contained in:
eugene yokota 2018-01-22 14:14:35 -05:00 committed by GitHub
commit 5d89795657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 14 deletions

View File

@ -9,7 +9,7 @@ def buildLevelSettings: Seq[Setting[_]] =
inThisBuild(
Seq(
organization := "org.scala-sbt",
version := "1.1.0-SNAPSHOT",
version := "1.1.1-SNAPSHOT",
description := "sbt is an interactive build tool",
bintrayOrganization := Some("sbt"),
bintrayRepository := {

View File

@ -1366,12 +1366,13 @@ object Defaults extends BuildCommon {
(compilers in task).value.scalac match {
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala"))
}
(new Console(compiler))(cpFiles,
(scalacOptions in task).value,
loader,
(initialCommands in task).value,
(cleanupCommands in task).value)()(s.log).get
println()
val sc = (scalacOptions in task).value
val ic = (initialCommands in task).value
val cc = (cleanupCommands in task).value
JLine.usingTerminal { _ =>
(new Console(compiler))(cpFiles, sc, loader, ic, cc)()(s.log).get
println()
}
}
private[this] def exported(w: PrintWriter, command: String): Seq[String] => Unit =

View File

@ -9,6 +9,7 @@ package sbt
package internal
import sbt.util.Logger
import sbt.internal.util.JLine
import sbt.internal.inc.{ ScalaInstance, ZincUtil }
import xsbti.compile.ClasspathOptionsUtil
@ -42,13 +43,17 @@ object ConsoleProject {
val imports = BuildUtil.getImports(unit.unit) ++ BuildUtil.importAll(bindings.map(_._1))
val importString = imports.mkString("", ";\n", ";\n\n")
val initCommands = importString + extra
// TODO - Hook up dsl classpath correctly...
(new Console(compiler))(
unit.classpath,
options,
initCommands,
cleanupCommands
)(Some(unit.loader), bindings)
JLine.usingTerminal { _ =>
// TODO - Hook up dsl classpath correctly...
(new Console(compiler))(
unit.classpath,
options,
initCommands,
cleanupCommands
)(Some(unit.loader), bindings)
}
()
}
/** Conveniences for consoleProject that shouldn't normally be used for builds. */

View File

@ -0,0 +1,13 @@
[@eed3si9n]: https://github.com/eed3si9n
[3841]: https://github.com/sbt/sbt/issues/3841
[3876]: https://github.com/sbt/sbt/pull/3876
### Fixes with compatibility implications
### Improvements
### Bug fixes
- Fixes tab completion in `console` while running in batch mode as `sbt console`. [#3841][3841]/[#3876][3876] by [@eed3si9n][@eed3si9n]