boolean (@Nullable TextRange oldCursorRange) { if (oldCursorRange == null) return false; FindResult mayBeOldCursor = null; for (FindResult searchResult : getOccurrences()) { if (searchResult.intersects(oldCursorRange)) { mayBeOldCursor = searchResult; } if (searchResult.getStartOffset() == oldCursorRange.getStartOffset()) { break; } } if (mayBeOldCursor != null) { myCursor = mayBeOldCursor; return true; } return false; }