Source:
public Annotation gotoAnnotation(Direction direction) { if (leftSourceViewer == null) { return null; } int currentLeftOffset = 0; if (getCurrentSide() == RIGHT_SIDE && rightSourceViewer != null) { currentLeftOffset = getSelection(rightSourceViewer).getOffset(); int endOfDocument = currentLeftOffset - 1; if (currentLeftOffset == 0) { IDocument document = leftAnnotationModel.getDocument(); if (document != null) { endOfDocument = document.getLength(); } } leftSourceViewer.getSourceViewer().setSelectedRange(endOfDocument, 1); } else { currentLeftOffset = getSelection(leftSourceViewer).getOffset(); int endOfDocument = currentLeftOffset + 1; IDocument document = rightAnnotationModel.getDocument(); if (document != null) { if (endOfDocument > document.getLength()) { endOfDocument = document.getLength(); } } rightSourceViewer.getSourceViewer().setSelectedRange(endOfDocument, 1); } Position nextLeftPosition = new Position(0, 0); Annotation leftAnnotation = findAnnotation(leftSourceViewer, direction, nextLeftPosition, leftAnnotationModel); Position nextRightPosition = new Position(0, 0); Annotation rightAnnotation = findAnnotation(rightSourceViewer, direction, nextRightPosition, rightAnnotationModel); if (leftAnnotation == null && rightAnnotation != null) { selectAndReveal(rightSourceViewer, nextRightPosition); return rightAnnotation; } else if (leftAnnotation != null && rightAnnotation == null) { selectAndReveal(leftSourceViewer, nextLeftPosition); return leftAnnotation; } else if (leftAnnotation != null && rightAnnotation != null) { nextLeftPosition.offset = getLineOffset(leftAnnotationModel, nextLeftPosition.offset); nextLeftPosition.length = 1; nextRightPosition.offset = getLineOffset(rightAnnotationModel, nextRightPosition.offset); nextRightPosition.length = 1; if (calculateNextAnnotation(direction, nextLeftPosition, nextRightPosition, currentLeftOffset) == LEFT_SIDE) { return leftAnnotation; } else { return rightAnnotation; } } return null; }

Target:
public Annotation gotoAnnotation(Direction direction) { if (leftSourceViewer == null || rightSourceViewer == null) { return null; } int currentOffset = getLastSelectionOffset(); Position nextLeftPosition = new Position(0, 0); Annotation leftAnnotation = findAnnotation(leftSourceViewer, direction, nextLeftPosition, leftAnnotationModel); Position nextRightPosition = new Position(0, 0); Annotation rightAnnotation = findAnnotation(rightSourceViewer, direction, nextRightPosition, rightAnnotationModel); if (leftAnnotation == null && rightAnnotation != null) { moveToRightAnnotation(nextRightPosition); return rightAnnotation; } else if (leftAnnotation != null && rightAnnotation == null) { moveToLeftAnnotation(nextLeftPosition); return leftAnnotation; } else if (leftAnnotation != null && rightAnnotation != null) { nextLeftPosition.offset = getLineOffset(leftAnnotationModel, nextLeftPosition.offset); nextLeftPosition.length = 1; nextRightPosition.offset = getLineOffset(rightAnnotationModel, nextRightPosition.offset); nextRightPosition.length = 1; if (calculateNextAnnotation(direction, nextLeftPosition, nextRightPosition, currentOffset) == LEFT_SIDE) { return leftAnnotation; } else { return rightAnnotation; } } return null; }