int (@NotNull Iterator<? extends Pair<Integer, CharSequence>> changedLinesIterator) { // we ignore spaces.. at least at start/end, since some version controls could ignore their changes when doing annotate Iterator<? extends CharSequence> iterator = getPreviousLinesIterable().iterator(); if (iterator.hasNext()) { CharSequence contextLine = iterator.next(); while (changedLinesIterator.hasNext()) { Pair<Integer, ? extends CharSequence> pair = changedLinesIterator.next(); if (StringUtil.equalsTrimWhitespaces(pair.getSecond(), contextLine)) { if (!iterator.hasNext()) break; contextLine = iterator.next(); } } } if (iterator.hasNext()) return -1; if (!changedLinesIterator.hasNext()) return -1; while (changedLinesIterator.hasNext()) { Pair<Integer, ? extends CharSequence> pair = changedLinesIterator.next(); if (StringUtil.equalsTrimWhitespaces(pair.getSecond(), getTargetString())) { return pair.getFirst(); } } return -1; }