Skip to content

Commit ce2d44f

Browse files
authored
fix: fix Jansi AnsiConsole broken color detection in uber jars (#1305)
The AnsiType detection logic was incorrectly inverted, causing colors to be disabled in uber jar scenarios. When getSystemStream() returns null (indicating a native terminal), the type should be AnsiType.Native, not AnsiType.Redirected. This fix corrects the ternary operator logic: - When getSystemStream() == null: AnsiType.Redirected (output is redirected) - When getSystemStream() != null: AnsiType.Native (native terminal with color support) The original Jansi library worked in uber jars because it had different terminal detection logic. JLine's Jansi compatibility layer was incorrectly marking native terminals as redirected, which disabled ANSI color processing. This simple but critical fix ensures that: - Colors work correctly in uber jars on Windows and other platforms - Native terminal detection works as expected - ANSI escape sequences are properly processed instead of being stripped - Maintains full backward compatibility with existing applications Fixes #1292
1 parent ac97af1 commit ce2d44f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

jansi-core/src/main/java/org/jline/jansi/AnsiConsole.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private static AnsiPrintStream ansiStream(boolean stdout) throws IOException {
238238
width = terminal::getWidth;
239239
type = terminal instanceof DumbTerminal
240240
? AnsiType.Unsupported
241-
: ((TerminalExt) terminal).getSystemStream() != null ? AnsiType.Redirected : AnsiType.Native;
241+
: ((TerminalExt) terminal).getSystemStream() != null ? AnsiType.Native : AnsiType.Redirected;
242242

243243
AnsiMode mode;
244244

0 commit comments

Comments
 (0)