String (@NotNull Editor editor, int offset, boolean shouldExpand) { CodeStyleSettings settings = CodeStyle.getSettings(editor); CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(ShFileType.INSTANCE); CharSequence docChars = editor.getDocument().getCharsSequence(); String baseIndent = ""; if (offset > 0) { int indentStart = CharArrayUtil.shiftBackwardUntil(docChars, offset, "\n") + 1; if (indentStart >= 0) { int indentEnd = CharArrayUtil.shiftForward(docChars, indentStart, " \t"); int diff = indentEnd - indentStart; if (diff > 0) { if (shouldExpand) { baseIndent = docChars.subSequence(indentStart, indentEnd).toString(); } else { if (diff >= indentOptions.INDENT_SIZE) { baseIndent = docChars.subSequence(indentStart, indentEnd - indentOptions.INDENT_SIZE).toString(); } } } } } if (shouldExpand) { baseIndent += new IndentInfo(0, indentOptions.INDENT_SIZE, 0).generateNewWhiteSpace(indentOptions); } return baseIndent; }