int (int originalOffset, @NotNull List<? extends TextChange> changes) { int offset = originalOffset; for (TextChange change : changes) { if (originalOffset > change.getStart()) { offset += change.getText().length() - (change.getEnd() - change.getStart()); } } return offset; }