mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-206288 [large file] Add ensuring that requested page number is in valid bounds
GitOrigin-RevId: d0bea3ded7022c1966d38745607c999f4d8affe9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
90e915819b
commit
a5679f67cd
@@ -269,6 +269,7 @@ public class EditorModel {
|
||||
}
|
||||
|
||||
if (isNeedToShowCaret) {
|
||||
ensureTargetCaretPositionIsInFileBounds(pagesAmountInFile);
|
||||
targetVisiblePosition.set(targetCaretPosition.pageNumber,
|
||||
targetVisiblePosition.verticalScrollOffset); // we can't count the necessary offset at this stage
|
||||
}
|
||||
@@ -685,6 +686,15 @@ public class EditorModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ensureTargetCaretPositionIsInFileBounds(long pagesAmount) {
|
||||
if (targetCaretPosition.pageNumber < 0) {
|
||||
targetCaretPosition.set(0, 0);
|
||||
}
|
||||
else if (targetCaretPosition.pageNumber >= pagesAmount) {
|
||||
targetCaretPosition.set(pagesAmount, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void normalizePagesInDocumentListEnding() {
|
||||
int visibleTargetPageIndex = tryGetIndexOfNeededPageInList(targetVisiblePosition.pageNumber);
|
||||
if (visibleTargetPageIndex == -1) {
|
||||
|
||||
@@ -121,16 +121,12 @@ class FileAdapter {
|
||||
*/
|
||||
@NotNull
|
||||
String getPageText(long pageNumber) throws IOException {
|
||||
|
||||
randomAccessFileLock.lock();
|
||||
try {
|
||||
|
||||
/*DEBUG BEGIN*/
|
||||
//java.util.Random rand = new java.util.Random(System.currentTimeMillis());
|
||||
//if (true) try { Thread.sleep(rand.nextInt(100));} catch (InterruptedException e) {}
|
||||
//if (rand.nextInt(10) < 1) throw new FileNotFoundException();
|
||||
//try { Thread.sleep(10);} catch (InterruptedException e) {}
|
||||
/*DEBUG END*/
|
||||
long pagesAmount = getPagesAmount();
|
||||
if (pageNumber < 0 || pageNumber >= pagesAmount) {
|
||||
throw new IllegalArgumentException("pageNumber=" + pageNumber + ", pagesAmount=" + pagesAmount);
|
||||
}
|
||||
|
||||
long minProbStartPos;
|
||||
long startByte;
|
||||
|
||||
Reference in New Issue
Block a user