Skip to content

Commit

Permalink
Disable ANSI support when running in IntelliJ regardless of reported …
Browse files Browse the repository at this point in the history
…TTY support. As a result of this, no run output will be coloured in IntelliJ, but this seems marginally better than having output that is corrupt when viewed in certain modes.

This is a workaround for issues described elsewhere:
fusesource/jansi#31
https://youtrack.jetbrains.com/issue/IDEA-132822

Refs #1
  • Loading branch information
rnorth committed Jul 15, 2017
1 parent 906b3fb commit 15163a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/rnorth/visibleassertions/AnsiSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.rnorth.visibleassertions;

import jline.TerminalFactory;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.AnsiConsole;

import java.io.PrintStream;
Expand All @@ -35,6 +36,15 @@ public class AnsiSupport {
static PrintStream writer = System.out;

protected synchronized static void initialize() {

try {
Class.forName("com.intellij.rt.execution.application.AppMain");
// Running in IntelliJ - disable ANSI output
Ansi.setEnabled(false);
} catch (ClassNotFoundException e) {
// Not running in IntelliJ - assume TTY detection works correctly
}

AnsiConsole.systemInstall();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void setup() {

@After
public void outputForDebugging() {
System.out.println("CAPTURED STDOUT:");
System.out.println(getCapturedStdOut());
}

Expand Down

0 comments on commit 15163a4

Please sign in to comment.