diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-31 15:33:21 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-31 15:33:21 -0500 |
commit | d7e2d3d4f13c5f6e52ad36aa890eb09a650d1238 (patch) | |
tree | 9e4d883716a34fcbaef46fe943bb35242a33b675 /buffer.c | |
parent | 5a7ca9106a305555922ef78c2dd84ab8779c7718 (diff) |
fixed Ctrl+Left/Right being double-set, cleaned up core options code, auto-add-newline
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -643,6 +643,7 @@ void buffer_new_file(TextBuffer *buffer, char const *filename) { // Save the buffer to its current filename. This will rewrite the entire file, regardless of // whether there are any unsaved changes. bool buffer_save(TextBuffer *buffer) { + Settings const *settings = buffer_settings(buffer); if (!buffer->is_line_buffer && buffer->filename) { FILE *out = fopen(buffer->filename, "wb"); if (out) { @@ -659,6 +660,13 @@ bool buffer_save(TextBuffer *buffer) { if (line != end-1) { putc('\n', out); + } else { + if (settings->auto_add_newline) { + if (line->len) { + // if the last line isn't empty, add a newline. + putc('\n', out); + } + } } } if (ferror(out)) { |