From b599762fe6157326f938839bedc254ca7a51eafa Mon Sep 17 00:00:00 2001 From: Frank Fesevur Date: Mon, 11 Feb 2019 09:56:02 +0100 Subject: [PATCH] Convert EOL when saving the file --- src/PluginDefinition.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/PluginDefinition.cpp b/src/PluginDefinition.cpp index 9e84e78..6312937 100644 --- a/src/PluginDefinition.cpp +++ b/src/PluginDefinition.cpp @@ -281,9 +281,9 @@ void onBeforeSave(HWND hWnd) int trim_trailing_whitespace = NPPEC_BOOLVAL_UNSPECIFIED; int insert_final_newline = NPPEC_BOOLVAL_UNSPECIFIED; + int end_of_line = 0; int name_value_count = editorconfig_handle_get_name_value_count(eh); - for (int i = 0; i < name_value_count; ++i) { const char* name; const char* value; @@ -307,6 +307,17 @@ void onBeforeSave(HWND hWnd) } continue; } + + // Need to convert the end of lines? + if (strcmp(name, "end_of_line") == 0) { + if (strcmp(value, "lf") == 0) + end_of_line = IDM_FORMAT_TOUNIX; + else if (strcmp(value, "crlf") == 0) + end_of_line = IDM_FORMAT_TODOS; + else if (strcmp(value, "cr") == 0) + end_of_line = IDM_FORMAT_TOMAC; + continue; + } } // Save the folding behavior and set it to 0 to keep folds from opening @@ -325,6 +336,10 @@ void onBeforeSave(HWND hWnd) insertFinalNewline(insert_final_newline == NPPEC_BOOLVAL_TRUE); } + if (end_of_line != 0) { + SendMessage(hWnd, NPPM_MENUCOMMAND, 0, end_of_line); + } + // Restore the folding behavior SendMessage(curScintilla, SCI_SETAUTOMATICFOLD, automatic_fold, 0);