mirror of https://github.com/sbt/sbt.git
Fix tab completion running `sbt console`
Fixes #3841 This fixes console task that internally uses JLine. When `console` is started from batch mode, the tab is printed as is. This is because JLine is not initialized yet. Calling `usingTerminal` initializes and restores the terminal afterwards.
This commit is contained in:
parent
e58b303297
commit
ca712acf41
|
|
@ -1366,12 +1366,13 @@ object Defaults extends BuildCommon {
|
||||||
(compilers in task).value.scalac match {
|
(compilers in task).value.scalac match {
|
||||||
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala"))
|
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala"))
|
||||||
}
|
}
|
||||||
(new Console(compiler))(cpFiles,
|
val sc = (scalacOptions in task).value
|
||||||
(scalacOptions in task).value,
|
val ic = (initialCommands in task).value
|
||||||
loader,
|
val cc = (cleanupCommands in task).value
|
||||||
(initialCommands in task).value,
|
JLine.usingTerminal { _ =>
|
||||||
(cleanupCommands in task).value)()(s.log).get
|
(new Console(compiler))(cpFiles, sc, loader, ic, cc)()(s.log).get
|
||||||
println()
|
println()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private[this] def exported(w: PrintWriter, command: String): Seq[String] => Unit =
|
private[this] def exported(w: PrintWriter, command: String): Seq[String] => Unit =
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ package sbt
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
|
import sbt.internal.util.JLine
|
||||||
import sbt.internal.inc.{ ScalaInstance, ZincUtil }
|
import sbt.internal.inc.{ ScalaInstance, ZincUtil }
|
||||||
import xsbti.compile.ClasspathOptionsUtil
|
import xsbti.compile.ClasspathOptionsUtil
|
||||||
|
|
||||||
|
|
@ -42,13 +43,17 @@ object ConsoleProject {
|
||||||
val imports = BuildUtil.getImports(unit.unit) ++ BuildUtil.importAll(bindings.map(_._1))
|
val imports = BuildUtil.getImports(unit.unit) ++ BuildUtil.importAll(bindings.map(_._1))
|
||||||
val importString = imports.mkString("", ";\n", ";\n\n")
|
val importString = imports.mkString("", ";\n", ";\n\n")
|
||||||
val initCommands = importString + extra
|
val initCommands = importString + extra
|
||||||
// TODO - Hook up dsl classpath correctly...
|
|
||||||
(new Console(compiler))(
|
JLine.usingTerminal { _ =>
|
||||||
unit.classpath,
|
// TODO - Hook up dsl classpath correctly...
|
||||||
options,
|
(new Console(compiler))(
|
||||||
initCommands,
|
unit.classpath,
|
||||||
cleanupCommands
|
options,
|
||||||
)(Some(unit.loader), bindings)
|
initCommands,
|
||||||
|
cleanupCommands
|
||||||
|
)(Some(unit.loader), bindings)
|
||||||
|
}
|
||||||
|
()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Conveniences for consoleProject that shouldn't normally be used for builds. */
|
/** Conveniences for consoleProject that shouldn't normally be used for builds. */
|
||||||
|
|
|
||||||
|
|
@ -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]
|
||||||
Loading…
Reference in New Issue