private int getSearchStart(int startPosition, boolean isForward) {

		FindMatch activeMatch = searchResults.getActiveMatch();
		if (activeMatch == null) {
			return startPosition;
		}

		int lastMatchStart = activeMatch.getStart();
		if (startPosition != lastMatchStart) {
			return startPosition;
		}

		// Always prefer the caret position, unless it aligns with the previous match.  By
		// moving it forward one we will continue our search, as opposed to always matching
		// the same hit.
		if (isForward) {
			return startPosition + 1;
		}

		// backwards
		if (startPosition == 0) {
			return editorPane.getText().length();
		}
		return startPosition - 1;
	}
A class to find text matches in the given {@link TextComponent}.  This class will search for all
matches and cache the results for future requests when the user presses Next or Previous.  All
matches will be highlighted in the text component.  The match containing the cursor will be a 
different highlight color than the others.  When the find dialog is closed, all highlights are
removed.
Ghidra/Framework/Docking/src/main/java/docking/widgets/TextComponentSearcher.java