int (@NotNull List<? extends TokenBuffer.TokenInfo> source, int sourceStartIndex, @NotNull List<? super TokenBuffer.TokenInfo> dest) { int backspacesFromNextToken = 0; for (int i = source.size() - 1; i >= sourceStartIndex; i--) { TokenBuffer.TokenInfo token = source.get(i); TokenBuffer.TokenInfo newToken; if (StringUtil.containsChar(token.getText(), BACKSPACE) || backspacesFromNextToken > 0) { StringBuilder tokenTextBuilder = new StringBuilder(token.getText().length() + backspacesFromNextToken); tokenTextBuilder.append(token.getText()); StringUtil.repeatSymbol(tokenTextBuilder, BACKSPACE, backspacesFromNextToken); normalizeBackspaceCharacters(tokenTextBuilder); backspacesFromNextToken = getBackspacePrefixLength(tokenTextBuilder); String newText = tokenTextBuilder.substring(backspacesFromNextToken); newToken = new TokenBuffer.TokenInfo(token.contentType, newText, token.getHyperlinkInfo()); } else { newToken = token; } dest.add(newToken); } Collections.reverse(dest); return backspacesFromNextToken; }