From ac8ef58e95a8134c5e22b0183914a5f7552220a6 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 9 Sep 2016 13:29:40 -0400 Subject: [PATCH] fixed bug that was preventing command line file loading --- 4coder_string.h | 2 +- 4ed.cpp | 10 +++++++--- 4ed_file_view.cpp | 12 +++++------- TODO.txt | 2 +- internal_4coder_string.cpp | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/4coder_string.h b/4coder_string.h index eeafb33b..04ded501 100644 --- a/4coder_string.h +++ b/4coder_string.h @@ -396,7 +396,7 @@ make_string_slowly(void *str) String result; result.str = (char*)str; result.size = str_size((char*)str); - result.memory_size = result.size; + result.memory_size = result.size+1; return(result); } #endif diff --git a/4ed.cpp b/4ed.cpp index f0613e18..3e349a9f 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -1991,13 +1991,13 @@ App_Step_Sig(app_step){ i32 i = 0; Panel *panel = models->layout.used_sentinel.next; - for (; i < models->settings.init_files_count; - ++i, panel = panel->next){ + for (; i < models->settings.init_files_count; ++i, panel = panel->next){ String filename = make_string_slowly(models->settings.init_files[i]); if (i < models->layout.panel_count){ view_open_file(system, models, panel->view, filename); view_show_file(panel->view); + Assert("Earlier" && panel->view->file_data.file != 0); #if 0 if (i == 0){ if (panel->view->file_data.file){ @@ -2025,6 +2025,11 @@ App_Step_Sig(app_step){ view_set_file(panel->view, models->scratch_buffer, models); view_show_file(panel->view); } + + panel = models->layout.used_sentinel.next; + for (i = 0; i < models->settings.init_files_count; ++i, panel = panel->next){ + Assert(panel->view->file_data.file != 0); + } } // NOTE(allen): respond if the user is trying to kill the application @@ -2111,7 +2116,6 @@ App_Step_Sig(app_step){ #endif // NOTE(allen): Keyboard input to command coroutine. - if (models->command_coroutine != 0){ Coroutine *command_coroutine = models->command_coroutine; u32 get_flags = models->command_coroutine_flags[0]; diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 2f28b064..274781df 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -5320,19 +5320,17 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol i32 result = 0; GUI_Session gui_session = {0}; - GUI_Header *h; + GUI_Header *h = 0; GUI_Target *gui_target = &view->gui_target; GUI_Interpret_Result interpret_result = {0}; f32 v = {0}; - i32 max_y = view_compute_max_target_y(view); - i16 font_id = 0; - if (file){ - font_id = file->settings.font_id; - } + Assert(file != 0); + + font_id = file->settings.font_id; if (gui_target->push.pos > 0){ gui_session_init(&gui_session, gui_target, rect, view->line_height); @@ -5361,7 +5359,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol case guicom_file: { - if (file && file_is_ready(file)){ + if (file_is_ready(file)){ result = draw_file_loaded(view, gui_session.rect, is_active, target); } }break; diff --git a/TODO.txt b/TODO.txt index a3974db2..ca7c95df 100644 --- a/TODO.txt +++ b/TODO.txt @@ -87,6 +87,7 @@ ; BEFORE I SHIP ; +; [X] why are command line files not loading any more? ; [X] tokens in the custom API ; [X] token seeking on custom side ; [X] auto indent on the custom side @@ -97,7 +98,6 @@ ; [] expose dirty flags ; [] occasionally missing the (!) mark on files on windows ; [] scroll down on compilation buffer durring compilation -; [] why are command line files not loading any more? ; ; diff --git a/internal_4coder_string.cpp b/internal_4coder_string.cpp index d0791c98..24508240 100644 --- a/internal_4coder_string.cpp +++ b/internal_4coder_string.cpp @@ -197,7 +197,7 @@ treating that as the size and memory size of the string.) */{ String result; result.str = (char*)str; result.size = str_size((char*)str); - result.memory_size = result.size; + result.memory_size = result.size+1; return(result); }