diff --git a/CMakeLists.txt b/CMakeLists.txt index 0591ba4..817c1e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.8.8) project(juci) -set(JUCI_VERSION "1.2.4-1") +set(JUCI_VERSION "1.2.4-2") set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim ") diff --git a/src/config.cc b/src/config.cc index afe484d..8e00ad9 100644 --- a/src/config.cc +++ b/src/config.cc @@ -172,6 +172,7 @@ void Config::read(const boost::property_tree::ptree &cfg) { source.cleanup_whitespace_characters=source_json.get("cleanup_whitespace_characters"); source.show_whitespace_characters=source_json.get("show_whitespace_characters"); source.format_style_on_save=source_json.get("format_style_on_save"); + source.format_style_on_save_if_style_file_found=source_json.get("format_style_on_save_if_style_file_found"); source.smart_brackets=source_json.get("smart_brackets"); source.smart_inserts=source_json.get("smart_inserts"); if(source.smart_inserts) diff --git a/src/config.h b/src/config.h index 20aa05e..b8c7941 100644 --- a/src/config.h +++ b/src/config.h @@ -73,6 +73,7 @@ public: std::string show_whitespace_characters; bool format_style_on_save; + bool format_style_on_save_if_style_file_found; bool smart_brackets; bool smart_inserts; diff --git a/src/files.h b/src/files.h index bb66c7b..9a277be 100644 --- a/src/files.h +++ b/src/files.h @@ -46,6 +46,8 @@ R"RAW( "show_whitespace_characters": "", "format_style_on_save_comment": "Performs clang-format on save for C/C++ and other curly-bracket languages supported by clang-format", "format_style_on_save": false, + "format_style_on_save_if_style_file_found_comment": "Format style if format file is found, even if format_style_on_save is false", + "format_style_on_save_if_style_file_found": false, "smart_brackets_comment": "If smart_inserts is enabled, this option is automatically enabled. When inserting an already closed bracket, the cursor might instead be moved, avoiding the need of arrow keys after autocomplete", "smart_brackets": true, "smart_inserts_comment": "When for instance inserting (, () gets inserted. Applies to: (), [], \", '. Also enables pressing ; inside an expression before a final ) to insert ; at the end of line, and deletions of empty insertions", diff --git a/src/source.cc b/src/source.cc index 8580112..91f069e 100644 --- a/src/source.cc +++ b/src/source.cc @@ -167,7 +167,7 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtrget_id()=="go" || language->get_id()=="scala" || language->get_id()=="opencl")) { is_bracket_language=true; - format_style=[this]() { + format_style=[this](bool continue_without_style_file) { auto command=Config::get().terminal.clang_format_command+" -output-replacements-xml -assume-filename="+filesystem::escape_argument(this->file_path.string()); if(get_buffer()->get_has_selection()) { @@ -191,6 +191,8 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtr &views) { if(Config::get().source.cleanup_whitespace_characters) cleanup_whitespace_characters(); - if(Config::get().source.format_style_on_save && format_style) - format_style(); + if(format_style) { + if(Config::get().source.format_style_on_save) + format_style(true); + else if(Config::get().source.format_style_on_save_if_style_file_found) + format_style(false); + } if(filesystem::write(file_path, get_buffer())) { boost::system::error_code ec; diff --git a/src/source.h b/src/source.h index 2c5fcd1..c55967d 100644 --- a/src/source.h +++ b/src/source.h @@ -66,7 +66,7 @@ namespace Source { Glib::RefPtr language; std::function non_interactive_completion; - std::function format_style; + std::function format_style; std::function get_declaration_location; std::function(const std::vector &views)> get_implementation_locations; std::function(const std::vector &views)> get_declaration_or_implementation_locations; diff --git a/src/window.cc b/src/window.cc index 82ae6d0..075d6cd 100644 --- a/src/window.cc +++ b/src/window.cc @@ -531,7 +531,7 @@ void Window::set_menu_actions() { menu.add_action("source_indentation_auto_indent_buffer", [this]() { auto view=Notebook::get().get_current_view(); if(view && view->format_style) - view->format_style(); + view->format_style(true); }); menu.add_action("source_goto_line", [this]() {