package com.reason.bs;

import com.intellij.execution.*;
import com.intellij.execution.configurations.*;
import com.intellij.execution.process.*;
import com.intellij.openapi.util.*;
import com.reason.Compiler;
import org.jetbrains.annotations.*;

class BsColoredProcessHandler extends KillableProcessHandler implements AnsiEscapeDecoder.ColoredTextAcceptor {

    private final @NotNull AnsiEscapeDecoder m_ansiEscapeDecoder = new AnsiEscapeDecoder();
    private final @Nullable Compiler.ProcessTerminated m_onProcessTerminated;

    BsColoredProcessHandler(@NotNull GeneralCommandLine commandLine, @Nullable Compiler.ProcessTerminated onProcessTerminated) throws ExecutionException {
        super(commandLine);
        m_onProcessTerminated = onProcessTerminated;
    }

    @Override
    protected void onOSProcessTerminated(int exitCode) {
        super.onOSProcessTerminated(exitCode);
        if (m_onProcessTerminated != null) {
            m_onProcessTerminated.run();
        }
    }

    @Override
    public final void notifyTextAvailable(@NotNull final String text, @NotNull final Key outputType) {
        m_ansiEscapeDecoder.escapeText(text, outputType, super::notifyTextAvailable);
    }

    @Override
    public void coloredTextAvailable(@NotNull String text, @NotNull Key attributes) {
        super.notifyTextAvailable(text, attributes);
    }
}

@@ -1148,52 +1148,448 @@
 ext(
-text, outputType, super::notifyTextAvailable
+%0A                text,%0A                outputType,%0A                (chunk, attributes) -%3E %7B%0A                    if (%22:%22.equals(chunk)) %7B%0A                        // Suppose this is the separator in output: C:%5Cxxx%5Cxxx%5CFile.re : 1:13-14%0A                        super.notifyTextAvailable(%22 %22, attributes);%0A                    %7D else %7B%0A                        super.notifyTextAvailable(chunk, attributes);%0A                    %7D%0A                %7D
 );%0A 

Fix file pattern introduced in 8.3.0