Skip to content

Commit

Permalink
Allow JLine to fall back to a dump terminal
Browse files Browse the repository at this point in the history
Set the `dumb` JLine option to `null` instead of `false` when it is not forced. This allows JLine to fall back to a dumb terminal.
  • Loading branch information
mbovel committed Aug 5, 2024
1 parent b981231 commit 7f80d5f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions compiler/src/dotty/tools/repl/JLineTerminal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ class JLineTerminal extends java.io.Closeable {
// Logger.getLogger("org.jline").setLevel(Level.FINEST)

private val terminal =
TerminalBuilder.builder()
.dumb(dumbTerminal) // fail early if not able to create a terminal
.build()
var builder = TerminalBuilder.builder()
if System.getenv("TERM") == "dumb" then
// Force dumb terminal if `TERM` is `"dumb"`.
// Note: the default value for the `dumb` option is `null`, which allows
// JLine to fall back to a dumb terminal. This is different than `true` or
// `false` and can't be set using the `dumb` setter.
// This option is used at https://github.com/jline/jline3/blob/894b5e72cde28a551079402add4caea7f5527806/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java#L528.
builder.dumb(true)
builder.build()
private val history = new DefaultHistory
def dumbTerminal = Option(System.getenv("TERM")) == Some("dumb")

private def blue(str: String)(using Context) =
if (ctx.settings.color.value != "never") Console.BLUE + str + Console.RESET
Expand Down

0 comments on commit 7f80d5f

Please sign in to comment.