diff --git a/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java b/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java index 38f2aea647e9..2d60b9a7f9f7 100644 --- a/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java +++ b/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java @@ -63,6 +63,9 @@ public class AnsiEscapeDecoder { if (escSeqBeginInd < -1) { unhandledSuffixLength = decodeUnhandledSuffixLength(escSeqBeginInd); } + if (pos < text.length() - unhandledSuffixLength) { + chunks = processTextChunk(chunks, text.substring(pos, text.length() - unhandledSuffixLength), outputType, textAcceptor); + } break; } if (pos < escSeqBeginInd) { @@ -91,9 +94,6 @@ public class AnsiEscapeDecoder { pos = escSeqEndInd + 1; } updateUnhandledSuffix(text, outputType, unhandledSuffixLength); - if (unhandledSuffixLength == 0 && pos < text.length()) { - chunks = processTextChunk(chunks, text.substring(pos), outputType, textAcceptor); - } if (chunks != null && textAcceptor instanceof ColoredChunksAcceptor) { ((ColoredChunksAcceptor)textAcceptor).coloredChunksAvailable(chunks); } diff --git a/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java b/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java index 47d1fb9dcc7c..1886f2c50dc1 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java @@ -84,6 +84,13 @@ public class AnsiEscapeDecoderTest extends PlatformTestCase { .addExpected(":abcd", "\u001B[1;33m") .addExpected(">", "\u001B[0;1;33m") )); + check(false, ContainerUtil.newArrayList( + new ColoredText("\u001B[1;31m red\u001B[0m normal\u001B[1;32m green\u001B", ProcessOutputTypes.STDOUT) + .addExpected(" red", "\u001B[1;31m") + .addExpected(" normal", STDOUT_KEY) + .addExpected(" green", "\u001B[1;32m"), + new ColoredText("[0m\n", ProcessOutputTypes.STDOUT).addExpected("\n", STDOUT_KEY) + )); } public void testStderr() {