mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed exception in ConsoleViewImpl on typing immediately after multiple \r
This commit is contained in:
@@ -709,7 +709,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
try {
|
||||
myInDocumentUpdate = true;
|
||||
String[] strings = addedText.split("\\r");
|
||||
String[] strings = addedText.split("\\r", -1);
|
||||
for (int i = 0; i < strings.length - 1; i++) {
|
||||
document.insertString(document.getTextLength(), strings[i]);
|
||||
int lastLine = document.getLineCount() - 1;
|
||||
|
||||
@@ -17,10 +17,14 @@ package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.testFramework.TestDataProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -45,6 +49,28 @@ public class ConsoleViewImplTest extends LightPlatformTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testTypingAfterMultipleCR() throws Exception {
|
||||
final EditorActionManager actionManager = EditorActionManager.getInstance();
|
||||
final TypedAction typedAction = actionManager.getTypedAction();
|
||||
final TestDataProvider dataContext = new TestDataProvider(getProject());
|
||||
|
||||
final ConsoleViewImpl console = createConsole();
|
||||
final Editor editor = console.getEditor();
|
||||
try {
|
||||
console.print("System output\n", ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
console.print("\r\r\r\r\r\r\r", ConsoleViewContentType.NORMAL_OUTPUT);
|
||||
console.flushDeferredText();
|
||||
|
||||
typedAction.actionPerformed(editor, '1', dataContext);
|
||||
typedAction.actionPerformed(editor, '2', dataContext);
|
||||
|
||||
assertEquals("System output\n12", editor.getDocument().getText());
|
||||
}
|
||||
finally {
|
||||
Disposer.dispose(console);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ConsoleViewImpl createConsole() {
|
||||
Project project = getProject();
|
||||
|
||||
Reference in New Issue
Block a user