diff options
Diffstat (limited to 'ted.c')
-rw-r--r-- | ted.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -168,7 +168,10 @@ static Status ted_open_buffer(Ted *ted, u16 *buffer_idx, u16 *tab) { // Returns true on success static bool ted_open_file(Ted *ted, char const *filename) { u16 buffer_idx, tab_idx; - if (ted_open_buffer(ted, &buffer_idx, &tab_idx)) { + if (buffer_is_untitled(ted->active_buffer) && buffer_empty(ted->active_buffer)) { + // the active buffer is just an empty untitled buffer. open it here. + return buffer_load_file(ted->active_buffer, filename); + } else if (ted_open_buffer(ted, &buffer_idx, &tab_idx)) { TextBuffer *buffer = &ted->buffers[buffer_idx]; if (buffer_load_file(buffer, filename)) { return true; @@ -230,7 +233,7 @@ static bool ted_save_all(Ted *ted) { if (buffers_used[i]) { TextBuffer *buffer = &ted->buffers[i]; if (buffer_unsaved_changes(buffer)) { - if (buffer->filename && streq(buffer->filename, TED_UNTITLED)) { + if (buffer->filename && buffer_is_untitled(buffer)) { ted_switch_to_buffer(ted, i); menu_open(ted, MENU_SAVE_AS); success = false; // we haven't saved this buffer yet; we've just opened the "save as" menu. |