Browse Source

Force newline at end of file on prettier style format

merge-requests/413/head
eidheim 3 years ago
parent
commit
c2b824e51e
  1. 7
      src/source.cpp

7
src/source.cpp

@ -1001,6 +1001,8 @@ void Source::View::setup_format_style(bool is_generic_view) {
{
LockGuard lock(mutex);
if(result) {
if(!result->text.empty() && result->text.back() != '\n') // Workaround for prettier-plugin-latex that has missing newline at end of file
result->text += '\n';
replace_text(result->text);
if(result->cursor_offset >= 0 && result->cursor_offset < get_buffer()->size()) {
get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(result->cursor_offset));
@ -1047,7 +1049,10 @@ void Source::View::setup_format_style(bool is_generic_view) {
std::stringstream stdin_stream(get_buffer()->get_text().raw()), stdout_stream, stderr_stream;
auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path(), &stderr_stream);
if(exit_status == 0) {
replace_text(stdout_stream.str());
auto text = stdout_stream.str();
if(!text.empty() && text.back() != '\n') // Workaround for prettier-plugin-latex that has missing newline at end of file
text += '\n';
replace_text(text);
std::string line;
std::getline(stderr_stream, line);
if(!line.empty() && line != "NaN") {

Loading…
Cancel
Save