diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index e4ca30d8..3cf047b0 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -922,15 +922,15 @@ isearch(Application_Links *app, int start_reversed){ View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - User_Input in; - Query_Bar bar; if (!buffer.exists) return; + Query_Bar bar = {0}; if (app->start_query_bar(app, &bar, 0) == 0) return; int reverse = start_reversed; int pos = view.cursor.pos; + int start_pos = pos; Range match = make_range(pos, pos); char bar_string_space[256]; @@ -939,8 +939,9 @@ isearch(Application_Links *app, int start_reversed){ String isearch_str = make_lit_string("I-Search: "); String rsearch_str = make_lit_string("Reverse-I-Search: "); + User_Input in = {0}; for (;;){ - app->view_set_highlight(app, &view, match.start, match.end, 1); + app->view_set_highlight(app, &view, match.start, match.end, true); // NOTE(allen): Change the bar's prompt to match the current direction. if (reverse) bar.prompt = rsearch_str; @@ -1029,10 +1030,13 @@ isearch(Application_Links *app, int start_reversed){ } } } - app->view_set_highlight(app, &view, 0, 0, 0); - if (in.abort) return; + app->view_set_highlight(app, &view, 0, 0, false); + if (in.abort){ + app->view_set_cursor(app, &view, seek_pos(start_pos), true); + return; + } - app->view_set_cursor(app, &view, seek_pos(match.min), 1); + app->view_set_cursor(app, &view, seek_pos(match.min), true); } CUSTOM_COMMAND_SIG(search){ diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index d7b6450a..65561af2 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -122,6 +122,9 @@ imp_get_view(Command_Data *cmd, View_ID view_id){ view_id = view_id - 1; if (view_id >= 0 && view_id < live_set->max){ vptr = live_set->views + view_id; + if (!vptr->in_use){ + vptr = 0; + } } return(vptr); diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 0da5eb89..0c2ba1fc 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -1680,6 +1680,9 @@ view_set_temp_highlight(View *view, i32 pos, i32 end_pos){ view->file_data.temp_highlight = view_compute_cursor_from_pos(view, pos); view->file_data.temp_highlight_end_pos = end_pos; view->file_data.show_temp_highlight = 1; + + view_set_cursor(view, view->file_data.temp_highlight, + false, view->file_data.unwrapped_lines); } inline void @@ -1715,16 +1718,6 @@ view_set_file(View *view, Editing_File *file, Models *models){ if (file_is_ready(file)){ view_measure_wraps(&models->mem.general, view); - -#if 0 - edit_pos->cursor = view_compute_cursor_from_pos(view, 0); - edit_pos->scroll.max_y = view_compute_max_target_y(view); - edit_pos->preferred_x = view_get_cursor_x(view); - - view_move_view_to_cursor(view, &edit_pos->scroll, true); - view->reinit_scrolling = 1; -#endif - } } }