void invalidateRange(int startOffset, int endOffset) { if (myDocument.isInBulkUpdate()) return; if (myDocument.isInEventsHandling()) { myDocumentChangeStartOffset = Math.min(myDocumentChangeStartOffset, startOffset); myDocumentChangeEndOffset = Math.max(myDocumentChangeEndOffset, endOffset); } else if (myFoldingChangeEndOffset != Integer.MIN_VALUE) { // during batch folding processing we delay invalidation requests, as we cannot perform // coordinate conversions immediately myFoldingChangeStartOffset = Math.min(myFoldingChangeStartOffset, startOffset); myFoldingChangeEndOffset = Math.max(myFoldingChangeEndOffset, endOffset); } else { doInvalidateRange(startOffset, endOffset); } }
@Override public void onFoldProcessingEnd() { if (myDocument.isInBulkUpdate()) return; if (myFoldingChangeStartOffset <= myFoldingChangeEndOffset) { doInvalidateRange(myFoldingChangeStartOffset, myFoldingChangeEndOffset); } myFoldingChangeStartOffset = Integer.MAX_VALUE; myFoldingChangeEndOffset = Integer.MIN_VALUE; for (TextRange range : myDeferredRanges) { onTextLayoutPerformed(range.getStartOffset(), range.getEndOffset()); } myDeferredRanges.clear(); assertValidState(); }
private void onSoftWrapRecalculationEnd(IncrementalCacheUpdateEvent event) { if (myDocument.isInBulkUpdate()) return; boolean invalidate = true; if (myEditor.getFoldingModel().isInBatchFoldingOperation()) { myFoldingChangeStartOffset = Math.min(myFoldingChangeStartOffset, event.getStartOffset()); myFoldingChangeEndOffset = Math.max(myFoldingChangeEndOffset, event.getActualEndOffset()); invalidate = false; } if (myDocument.isInEventsHandling()) { myDocumentChangeStartOffset = Math.min(myDocumentChangeStartOffset, event.getStartOffset()); myDocumentChangeEndOffset = Math.max(myDocumentChangeEndOffset, event.getActualEndOffset()); invalidate = false; } if (invalidate) { doInvalidateRange(event.getStartOffset(), event.getActualEndOffset()); } }
void reset() { assert !myDocument.isInBulkUpdate(); doInvalidateRange(0, myDocument.getTextLength()); }
@Override public void documentChanged(DocumentEvent event) { if (myDocument.isInBulkUpdate()) return; doInvalidateRange(myDocumentChangeStartOffset, myDocumentChangeEndOffset); assertValidState(); }