void () { if (isDisposed) { return; } if (isBrokenMode) { documentOfPagesModel.removeAllPages(dataProvider.getProject()); return; } long pagesAmountInFile; try { pagesAmountInFile = dataProvider.getPagesAmount(); } catch (IOException e) { LOG.info(e); Messages.showErrorDialog(EditorBundle.message("large.file.editor.message.error.while.working.with.file.try.to.reopen.it"), CommonBundle.getErrorTitle()); return; } if (isNeedToShowCaret) { ensureTargetCaretPositionIsInFileBounds(pagesAmountInFile); targetVisiblePosition.set(targetCaretPosition.pageNumber, targetVisiblePosition.verticalScrollOffset); // we can't count the necessary offset at this stage } normalizePagesInDocumentListBeginning(); if (pagesAmountInFile == 0) { return; } if (documentOfPagesModel.getPagesAmount() == 0) { long pageNumber = targetVisiblePosition.pageNumber == 0 ? 0 : targetVisiblePosition.pageNumber == pagesAmountInFile // to avoid redundant document rebuilding ? targetVisiblePosition.pageNumber - 2 : targetVisiblePosition.pageNumber - 1; Page page = tryGetPageFromCash(pageNumber); if (page != null) { setNextPageIntoDocument(page); } else { requestReadPage(pageNumber); return; } } if (isNeedToTurnOnSoftWrapping()) { // TODO: 2019-05-21 need to notify user someway editor.getSettings().setUseSoftWraps(true); } normalizePagesInDocumentListEnding(); ensureDocumentLastPageIsValid(pagesAmountInFile); if (wasViewPortInTheEndOfFileLastTime && isAllowedToFollowTheEndOfFile) { targetVisiblePosition.set(Long.MAX_VALUE, 0); isNeedToShowCaret = false; isAllowedToFollowTheEndOfFile = false; } tryReflectTargetCaretPositionToReal(); tryReflectTargetSelectionToReal(); tryNormalizeTargetVisiblePosition(); if (!isLocalScrollBarStabilized) { tryScrollToTargetVisiblePosition(); } updateGlobalStrollBarView(); long nextPageNumberToAdd = tryGetNextPageNumberToAdd(pagesAmountInFile); if (nextPageNumberToAdd != -1) { Page nextPageToAdd = tryGetPageFromCash(nextPageNumberToAdd); if (nextPageToAdd != null) { setNextPageIntoDocument(nextPageToAdd); requestUpdate(); } else { requestReadPage(nextPageNumberToAdd); } return; } pagesCash.clear(); if (isNeedToShowCaret) { if (isLocalScrollBarStabilized) { showCaretThatIsNeededToShow(); } else { requestUpdate(); return; } } else { if (!isRealCaretMatchesTarget()) { setCaretToConvenientPosition(); } } wasViewPortInTheEndOfFileLastTime = false; if (documentOfPagesModel.getLastPage().getPageNumber() == pagesAmountInFile - 1 && myLocalInvisibleScrollBar.getValue() + myLocalInvisibleScrollBar.getHeight() == myLocalInvisibleScrollBar.getMaximum()) { wasViewPortInTheEndOfFileLastTime = true; } tryHighlightSearchResultsIfNeed(); }