krasa / GrepConsole

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7125
Apache License 2.0
437 stars 57 forks source link

Strange behavior when using ANSI colors #103

Closed lepe closed 6 years ago

lepe commented 6 years ago

IntelliJ version: 2017.3.3 GrepConsole version: 7.3.162

My output contains ANSI colors in the form: \u001B[31m, \u001B[0m, and so on...

If I select a word from the output and click "grep", it filter correctly the output (without colors), but after a second, only the filtered word is displayed, for example:

This is an example: 0
This is an example: 1
This is an example: 2
This is an example: 3
This is an example: 4
This is an example: 5
This 
This 
This 

If I click on "Reload", all the output is shown correct again, but after a second, it will only display the filtered word.

This is a sample code (using groovy):

static final String ANSI_RESET   = "\u001B[0m"
static final String ANSI_RED     = "\u001B[31m"
static final String ANSI_GREEN   = "\u001B[32m"
static final String ANSI_YELLOW  = "\u001B[33m"
static final String ANSI_BLUE    = "\u001B[34m"

def n = 0
while(true) {
    println ANSI_RED + "This " + ANSI_RESET + "is an example: " + ANSI_BLUE + n + ANSI_RESET
   println ANSI_GREEN + "That " + ANSI_RESET + ANSI_YELLOW + "is not the same..." + ANSI_RESET
    n++
    sleep(500)
}
krasa commented 6 years ago

I will probably have to always wait for a line break.