Fix console when supershell is disabled

The sbt console didn't work with supershell disabled because setting
that parameter was causing the terminal type to be dumb which only works
in some very specific situations. When Terminal.isAnsiSupported was
false, we were setting sbt to use a dumb terminal. We really only want
to use a dumb terminal if virtual io is off. It also doesn't necessarily
make sense to automatically disable general ansi codes even if
supershell is disabled by system property.
This commit is contained in:
Ethan Atkins 2020-11-04 15:44:14 -08:00
parent 3b09ff6af7
commit 7e1384608e
2 changed files with 3 additions and 5 deletions

View File

@ -306,9 +306,7 @@ object Terminal {
case _ => sys.props.get("sbt.log.format").flatMap(parseLogOption)
}
}
private[this] lazy val superShellEnabled = sys.props.get("sbt.supershell").map(_ == "true")
private[sbt] lazy val isAnsiSupported: Boolean =
logFormatEnabled.orElse(superShellEnabled).getOrElse(useColorDefault)
private[sbt] lazy val isAnsiSupported: Boolean = logFormatEnabled.getOrElse(useColorDefault)
private[this] val isDumbTerminal = "dumb" == System.getenv("TERM")
private[this] val hasConsole = Option(java.lang.System.console).isDefined
private[this] def useColorDefault: Boolean = {
@ -754,7 +752,7 @@ object Terminal {
private[this] def fixTerminalProperty(): Unit = {
val terminalProperty = "jline.terminal"
val newValue =
if (!isAnsiSupported) "none"
if (!isAnsiSupported && System.getProperty("sbt.io.virtual", "") == "false") "none"
else
System.getProperty(terminalProperty) match {
case "jline.UnixTerminal" => "unix"

View File

@ -163,7 +163,7 @@ case class TestServer(
val forkOptions =
ForkOptions()
.withOutputStrategy(OutputStrategy.StdoutOutput)
.withRunJVMOptions(Vector("-Dsbt.ci=true", "-Dsbt.io.virtual=false"))
.withRunJVMOptions(Vector("-Djline.terminal=none", "-Dsbt.io.virtual=false"))
val process =
RunFromSourceMain.fork(forkOptions, baseDirectory, scalaVersion, sbtVersion, classpath)