Merge pull request #6189 from eatkins/jline-console-close

Close jline 3 terminal when console exits
This commit is contained in:
eugene yokota 2020-12-03 13:01:59 -05:00 committed by GitHub
commit 4d1af77701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -65,15 +65,17 @@ final class Console(compiler: AnalyzingCompiler) {
)
} catch { case _: InterruptedException | _: ClosedChannelException => }
val previous = sys.props.get("scala.color").getOrElse("auto")
val jline3term = sbt.internal.util.JLine3(terminal)
try {
sys.props("scala.color") = if (terminal.isColorEnabled) "true" else "false"
terminal.withRawOutput {
jline.TerminalFactory.set(terminal.toJLine)
DeprecatedJLine.setTerminalOverride(sbt.internal.util.JLine3(terminal))
DeprecatedJLine.setTerminalOverride(jline3term)
terminal.withRawInput(Run.executeTrapExit(console0, log))
}
} finally {
sys.props("scala.color") = previous
jline3term.close()
}
}
}