CharSequence (@NotNull CharSequence whiteSpaceText, @NotNull CharSequence text, int startOffset, int endOffset, CodeStyleSettings codeStyleSettings, ASTNode nodeAfter) { // the general idea is that '\' symbol before line feed should be preserved Int2IntMap initialBackSlashes = countBackSlashes(text, startOffset, endOffset); if (initialBackSlashes.isEmpty()) { if (nodeAfter != null && whiteSpaceText.length() > 0 && whiteSpaceText.charAt(0) == '\n' && needInsertBackslash(nodeAfter, false)) { return addBackslashPrefix(whiteSpaceText, codeStyleSettings); } return whiteSpaceText; } Int2IntMap newBackSlashes = countBackSlashes(whiteSpaceText, 0, whiteSpaceText.length()); boolean continueProcessing = false; IntIterator iterator = initialBackSlashes.keySet().iterator(); while (iterator.hasNext()) { if (!newBackSlashes.containsKey(iterator.nextInt())) { continueProcessing = true; break; } } if (!continueProcessing) { return whiteSpaceText; } PyCodeStyleSettings settings = codeStyleSettings.getCustomSettings(PyCodeStyleSettings.class); StringBuilder result = new StringBuilder(); int line = 0; for (int i = 0; i < whiteSpaceText.length(); i++) { char c = whiteSpaceText.charAt(i); if (c != '\n') { result.append(c); continue; } if (!newBackSlashes.containsKey(line++)) { if ((i == 0 || whiteSpaceText.charAt(i - 1) != ' ') && settings.SPACE_BEFORE_BACKSLASH) { result.append(' '); } result.append('\\'); } result.append(c); } return result; }