diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-01 12:45:37 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-01 12:45:37 -0500 |
commit | e53329668e403a6b73bc8c9b56ad6b55eecba4e9 (patch) | |
tree | ca87e777053112f5de53155374f2272d6aad0ca1 /ted.c | |
parent | 11b50663dc489b7ec8cb1c8774d9bda2c7acac3b (diff) |
fix C hex literal highlighting
also open to untitled empty buffer
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. |