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 {
|
||||
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 =
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
|
|
|
|||
|
|
@ -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