Skip to content

Commit 7f80d5f

Browse files
committed
Allow JLine to fall back to a dump terminal
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.
1 parent b981231 commit 7f80d5f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

compiler/src/dotty/tools/repl/JLineTerminal.scala

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ class JLineTerminal extends java.io.Closeable {
2121
// Logger.getLogger("org.jline").setLevel(Level.FINEST)
2222

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

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

0 commit comments

Comments
 (0)