Browse Source

Now creates a tmp file in the users's tmp file directory when doing auto-indentation.

merge-requests/365/head
eidheim 10 years ago
parent
commit
6484c75e95
  1. 8
      src/source_clang.cc

8
src/source_clang.cc

@ -930,14 +930,16 @@ Source::ClangViewAutocomplete(file_path, project_path, language) {
});
auto_indent=[this]() {
boost::filesystem::path temp_file_path = boost::filesystem::unique_path();
boost::filesystem::path temp_file = "jucipp_auto_indent_tmp_file";
auto temp_directory=boost::filesystem::temp_directory_path();
boost::filesystem::path temp_file_path=temp_directory.string()+'/'+temp_file.string();
juci::filesystem::write(temp_file_path, get_buffer());
std::string command="clang-format \""+temp_file_path.string()+"\"";
command+=" -style=\"{IndentWidth: "+std::to_string(tab_size);
command+="}\"";
std::stringstream stdout_stream;
auto exit_code=Singleton::terminal()->execute(stdout_stream, command);
auto exit_code=Singleton::terminal()->execute(stdout_stream, command);
if(exit_code==0) {
get_source_buffer()->begin_user_action();
auto cursor_line_nr=get_buffer()->get_insert()->get_iter().get_line();
@ -948,6 +950,8 @@ Source::ClangViewAutocomplete(file_path, project_path, language) {
get_source_buffer()->end_user_action();
set_tab_char_and_size(' ', tab_size); //clang-format only does basic indentation with spaces as I understand it
}
boost::filesystem::remove(temp_file_path);
};
get_token=[this]() -> Token {

Loading…
Cancel
Save