use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class EditorImplTest method testCaretMergeDuringBulkModeDocumentUpdate.
public void testCaretMergeDuringBulkModeDocumentUpdate() throws Exception {
initText("a<selection>bcdef<caret></selection>g\n" + "a<selection>bcdef<caret></selection>g");
runWriteCommand(() -> {
DocumentEx document = (DocumentEx) myEditor.getDocument();
DocumentUtil.executeInBulk(document, true, () -> {
// delete selected text
document.deleteString(1, 6);
document.deleteString(4, 9);
});
});
checkResultByText("a<caret>g\n" + "a<caret>g");
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class EditorImplTest method testSoftWrapModeUpdateDuringBulkModeChange.
public void testSoftWrapModeUpdateDuringBulkModeChange() throws Exception {
initText("long long line<caret>");
configureSoftWraps(12);
DocumentEx document = (DocumentEx) myEditor.getDocument();
runWriteCommand(() -> {
DocumentUtil.executeInBulk(document, true, () -> {
document.replaceString(4, 5, "-");
});
});
assertEquals(new VisualPosition(1, 5), myEditor.getCaretModel().getVisualPosition());
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class EditorImplTest method testSuccessiveBulkModeOperations.
public void testSuccessiveBulkModeOperations() throws Exception {
initText("some text");
DocumentEx document = (DocumentEx) myEditor.getDocument();
runWriteCommand(() -> {
DocumentUtil.executeInBulk(document, true, () -> {
document.replaceString(4, 5, "-");
});
myEditor.getCaretModel().moveToOffset(9);
DocumentUtil.executeInBulk(document, true, () -> {
document.replaceString(4, 5, "+");
});
});
checkResultByText("some+text<caret>");
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class PsiDocumentManagerImplTest method testBackgroundCommitDoesNotChokeByWildChangesWhichInvalidatePsiFile.
public void testBackgroundCommitDoesNotChokeByWildChangesWhichInvalidatePsiFile() throws Exception {
@Language("JAVA") String text = "\n\nclass X {\npublic static final String string =null;\n public void x() {}\n}";
VirtualFile virtualFile = getVirtualFile(createTempFile("X.java", text));
PsiFile file = getPsiManager().findFile(virtualFile);
DocumentEx document = (DocumentEx) file.getViewProvider().getDocument();
PsiDocumentManager pdm = PsiDocumentManager.getInstance(myProject);
pdm.commitAllDocuments();
WriteCommandAction.runWriteCommandAction(null, () -> {
try {
virtualFile.setBinaryContent("\n txt txt txt".getBytes("UTF-8"));
virtualFile.rename(this, "X.txt");
} catch (IOException e) {
throw new RuntimeException(e);
}
});
DocumentCommitThread.getInstance().waitForAllCommits();
assertTrue(pdm.isCommitted(document));
assertFalse(file.isValid());
WriteCommandAction.runWriteCommandAction(null, () -> document.replaceString(0, document.getTextLength(), "xxxxxxxxxxxxxxxxxxxx"));
pdm.commitAllDocuments();
assertTrue(pdm.isCommitted(document));
PsiFile file2 = getPsiManager().findFile(virtualFile);
assertEquals(PlainTextLanguage.INSTANCE, file2.getLanguage());
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class RangeMarkerTest method testE6.
public void testE6() {
DocumentEx document = (DocumentEx) EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol(' ', 10));
List<RangeMarker> mm = add(document, 4, 8, 4, 4, 4, 9, 0, 2, 6, 8);
edit(document, 3, 2, 0);
}
Aggregations