mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
expand "\r" treatment on to the previous lines in document to fix IDEA-170961 sys.stdout is severly damaged and does not execute '\r' correctly
This commit is contained in:
@@ -685,7 +685,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
int startIndex = startsWithCR ? 1 : 0;
|
||||
for (int i = startIndex; i < deferredTokens.size(); i++) {
|
||||
TokenBuffer.TokenInfo deferredToken = deferredTokens.get(i);
|
||||
addedText.append(deferredToken.getText());
|
||||
addedText.append(deferredToken.getText()); // can just append texts because \r inside these tokens were already taken care of
|
||||
}
|
||||
if (startsWithCR) {
|
||||
// remove last line if any
|
||||
|
||||
@@ -65,13 +65,8 @@ class TokenBuffer {
|
||||
TokenInfo tokenInfo = new TokenInfo(contentType, text.substring(start, crIndex), info);
|
||||
tokens.addLast(tokenInfo);
|
||||
size += tokenInfo.length();
|
||||
removeLastLine();
|
||||
}
|
||||
else if (size == 0) {
|
||||
// \r at the very beginning. return CR_TOKEN to signal this
|
||||
tokens.addLast(CR_TOKEN);
|
||||
size ++;
|
||||
}
|
||||
removeLastLine();
|
||||
// text[start..crIndex) should be removed
|
||||
start = crIndex + 1;
|
||||
}
|
||||
@@ -110,10 +105,16 @@ class TokenBuffer {
|
||||
TokenInfo newToken = new TokenInfo(last.contentType, text.substring(0, lfIndex + 1), last.getHyperlinkInfo());
|
||||
tokens.addLast(newToken);
|
||||
size -= text.length() - newToken.length();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
// remove the token entirely, move to the previous
|
||||
size -= text.length();
|
||||
}
|
||||
if (tokens.isEmpty()) {
|
||||
// \r at the very beginning. return CR_TOKEN to signal this
|
||||
tokens.addLast(CR_TOKEN);
|
||||
size ++;
|
||||
}
|
||||
}
|
||||
|
||||
private void trim() {
|
||||
|
||||
@@ -374,4 +374,14 @@ public class ConsoleViewImplTest extends LightPlatformTestCase {
|
||||
() -> EditorTestUtil.executeAction(editor, true, handler),
|
||||
"", null, editor.getDocument());
|
||||
}
|
||||
|
||||
public void testCRPrintCR() throws Exception {
|
||||
for (int i=0;i<25;i++) {
|
||||
myConsole.print("\r"+i, ConsoleViewContentType.NORMAL_OUTPUT);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
myConsole.flushDeferredText();
|
||||
myConsole.waitAllRequests();
|
||||
assertEquals("24", myConsole.getText());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user