void () { List<? extends T> changes = getChanges(); int line = getEditor().getCaretModel().getLogicalPosition().line; T prev = null; for (int i = 0; i < changes.size(); i++) { T change = changes.get(i); T next = i < changes.size() - 1 ? changes.get(i + 1) : null; if (next == null || getEndLine(next) > line || getStartLine(next) >= line) { prev = change; break; } } assert prev != null; scrollToChangeUnderCommand(prev); }