TextWithMnemonic (@NotNull @Nls String text) { TextWithMnemonic mnemonic = text.isEmpty() ? EMPTY : fromMnemonicText(text); if (mnemonic != null) { return mnemonic; } if (text.contains("_") || text.contains("&")) { @Nls StringBuilder plainText = new StringBuilder(); int mnemonicIndex = -1; int backShift = 0; for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if (mnemonicIndex == -1 && (ch == '_' || ch == '&')) { //noinspection AssignmentToForLoopParameter i++; if (i >= text.length()) break; ch = text.charAt(i); if (ch != '_' && ch != '&') { mnemonicIndex = i - 1 - backShift; } else { backShift++; } } plainText.append(ch); } return fromPlainTextWithIndex(plainText.toString(), mnemonicIndex); } return fromPlainText(text); }