public void testSoftWrapModeUpdateDuringBulkModeChange() throws Exception { initText("long long line<caret>"); configureSoftWraps(12); DocumentEx document = (DocumentEx) myEditor.getDocument(); document.setInBulkUpdate(true); document.replaceString(4, 5, "-"); document.setInBulkUpdate(false); assertEquals(new VisualPosition(1, 5), myEditor.getCaretModel().getVisualPosition()); }
public void testUpdatingCaretPositionAfterBulkMode() throws Exception { initText("a<caret>bc"); DocumentEx document = (DocumentEx) myEditor.getDocument(); document.setInBulkUpdate(true); document.insertString( 0, "\n "); // we're changing number of visual lines, and invalidating text layout for caret // line document.setInBulkUpdate(false); checkResultByText("\n a<caret>bc"); }
public void testNoExceptionDuringBulkModeDocumentUpdate() throws Exception { initText("something"); DocumentEx document = (DocumentEx) myEditor.getDocument(); document.setInBulkUpdate(true); try { document.setText("something\telse"); } finally { document.setInBulkUpdate(false); } checkResultByText("something\telse"); }
public void testSuccessiveBulkModeOperations() throws Exception { initText("some text"); DocumentEx document = (DocumentEx) myEditor.getDocument(); document.setInBulkUpdate(true); document.replaceString(4, 5, "-"); document.setInBulkUpdate(false); myEditor.getCaretModel().moveToOffset(9); document.setInBulkUpdate(true); document.replaceString(4, 5, "+"); document.setInBulkUpdate(false); checkResultByText("some+text<caret>"); }
@NotNull @Override public HighlighterIterator createIterator(int startOffset) { synchronized (this) { final Document document = getDocument(); if (document instanceof DocumentEx && ((DocumentEx) document).isInBulkUpdate()) { ((DocumentEx) document).setInBulkUpdate(false); // bulk mode failed } if (mySegments.getSegmentCount() == 0 && document != null && document.getTextLength() > 0) { // bulk mode was reset doSetText(document.getCharsSequence()); } final int latestValidOffset = mySegments.getLastValidOffset(); return new HighlighterIteratorImpl( startOffset <= latestValidOffset ? startOffset : latestValidOffset); } }