diff --git a/python/src/com/jetbrains/python/formatter/PyCodeStyleSettings.java b/python/src/com/jetbrains/python/formatter/PyCodeStyleSettings.java index 3bf9855ff9e3..c060b782d1ad 100644 --- a/python/src/com/jetbrains/python/formatter/PyCodeStyleSettings.java +++ b/python/src/com/jetbrains/python/formatter/PyCodeStyleSettings.java @@ -31,8 +31,8 @@ public class PyCodeStyleSettings extends CustomCodeStyleSettings { public boolean SPACE_BEFORE_BACKSLASH = true; public int BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS = 2; - // TODO make boolean - public int NEW_LINE_AT_FILE_END = 1; + // TODO make boolean (it needs special editor in BlankLinesPanel) + public int BLANKS_LINES_AT_FILE_END = 1; public boolean ALIGN_COLLECTIONS_AND_COMPREHENSIONS = true; public boolean ALIGN_MULTILINE_IMPORTS = true; diff --git a/python/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java b/python/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java index 3780a5c1bcb4..ed213eaf36a9 100644 --- a/python/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java +++ b/python/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java @@ -88,7 +88,7 @@ public class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettin consumer.showCustomOption(PyCodeStyleSettings.class, "BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS", "Around top-level classes and functions:", BLANK_LINES); - consumer.showCustomOption(PyCodeStyleSettings.class, "NEW_LINE_AT_FILE_END", "New line at the end of file", BLANK_LINES); + consumer.showCustomOption(PyCodeStyleSettings.class, "BLANKS_LINES_AT_FILE_END", "Blank lines at the end of file", BLANK_LINES); } else if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) { consumer.showStandardOptions("RIGHT_MARGIN", diff --git a/python/src/com/jetbrains/python/formatter/PyTrailingBlankLinesPostFormatProcessor.java b/python/src/com/jetbrains/python/formatter/PyTrailingBlankLinesPostFormatProcessor.java index 597979169134..c3f475f15905 100644 --- a/python/src/com/jetbrains/python/formatter/PyTrailingBlankLinesPostFormatProcessor.java +++ b/python/src/com/jetbrains/python/formatter/PyTrailingBlankLinesPostFormatProcessor.java @@ -30,12 +30,15 @@ import com.jetbrains.python.psi.PyFile; import org.jetbrains.annotations.NotNull; /** - * Strip trailing extra blank lines at the end of the file and insert necessary line feed if corresponding whitespace element belongs to - * formatted range/element. If "Add new line at the file end" option was selected in Python code style settings final whitespace is replaced - * by single line feed, and it removed completely otherwise. - *
- * Note however that if option {@link EditorSettingsExternalizable#isEnsureNewLineAtEOF()} was also enabled line feed will be added at the - * end of file on next "Save" action regardless of the code style settings for Python. + * Handles extra blank lines at the end of the file if corresponding whitespace elements belong to formatted range/element. + * These trailing whitespaces are replaced by line feeds if either: + *