use of com.intellij.find.FindResult in project intellij-community by JetBrains.
the class SearchResults method repairCursorFromStack.
private boolean repairCursorFromStack() {
if (myCursorPositions.size() >= 2) {
final Pair<FindModel, FindResult> oldPosition = myCursorPositions.get(myCursorPositions.size() - 2);
if (oldPosition.first.equals(myFindModel)) {
FindResult newCursor;
if ((newCursor = findOccurrenceEqualTo(oldPosition.second)) != null) {
myCursorPositions.pop();
myCursor = newCursor;
return true;
}
}
}
return false;
}
use of com.intellij.find.FindResult in project intellij-community by JetBrains.
the class SearchResults method nextOccurrence.
private void nextOccurrence(boolean processFromTheBeginning, TextRange cursor, boolean toNotify, boolean justReplaced, boolean retainOldSelection) {
FindResult next;
if (myNotFoundState) {
myNotFoundState = false;
processFromTheBeginning = true;
}
if ((!myFindModel.isGlobal() || justReplaced) && cursor != null) {
next = nextOccurrence(cursor);
} else {
next = firstOccurrenceAfterCaret();
}
if (next == null) {
if (processFromTheBeginning) {
if (hasMatches()) {
next = getOccurrences().get(0);
}
} else {
setNotFoundState(true);
}
}
if (toNotify) {
moveCursorTo(next, retainOldSelection);
} else {
myCursor = next;
}
}
use of com.intellij.find.FindResult in project intellij-community by JetBrains.
the class SearchResults method updateCursor.
private void updateCursor(@Nullable TextRange oldCursorRange, @Nullable TextRange next) {
boolean justReplaced = next != null;
boolean toPush = true;
if (justReplaced || (toPush = !repairCursorFromStack())) {
if (justReplaced || !tryToRepairOldCursor(oldCursorRange)) {
if (myFindModel != null) {
if (oldCursorRange != null && !myFindModel.isGlobal()) {
myCursor = firstOccurrenceAfterOffset(oldCursorRange.getEndOffset());
} else {
if (justReplaced) {
nextOccurrence(false, next, false, true, false);
} else {
FindResult afterCaret = oldCursorRange == null ? firstOccurrenceAtOrAfterCaret() : firstOccurrenceAfterCaret();
if (afterCaret != null) {
myCursor = afterCaret;
} else {
myCursor = null;
}
}
}
} else {
myCursor = null;
}
}
}
if (!justReplaced && myCursor == null && hasMatches()) {
nextOccurrence(true, oldCursorRange, false, false, false);
}
if (toPush && myCursor != null) {
push();
}
}
Aggregations