mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix lost text tail when text ends with incomplete escape sequence
Bug occurred when text ends with \u001B' char (without following '[')
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
+7
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user