diff --git a/src/text_editor/commands_window.cpp b/src/text_editor/commands_window.cpp index 73d2dd6..2d635b4 100644 --- a/src/text_editor/commands_window.cpp +++ b/src/text_editor/commands_window.cpp @@ -703,7 +703,7 @@ void WindowCommand(Event event, Window *window, View *view) { } // @todo: consider making this view command - if (window->fuzzy_search && search) { + if (view->fuzzy_search && search) { Scratch scratch; String16 first_line_string = GetLineStringWithoutNL(*buffer, 0); Array ratings = FuzzySearchLines(scratch, buffer, 1, buffer->line_starts.len, first_line_string); @@ -724,7 +724,7 @@ void WindowCommand(Event event, Window *window, View *view) { view->carets[0] = caret; } - if (window->fuzzy_search) { + if (view->fuzzy_search) { if (Press(SDLK_RETURN)) { Scratch scratch; Buffer *buffer = GetBuffer(view->active_buffer); @@ -732,7 +732,7 @@ void WindowCommand(Event event, Window *window, View *view) { if (line == 0) line = 1; String16 string = GetLineStringWithoutNL(*buffer, line); - EvalString(scratch, string); + Open(string); // Clear text Command_SelectRangeOneCursor(view, GetLineRangeWithoutNL(*buffer, 0)); diff --git a/src/text_editor/lua_api.cpp b/src/text_editor/lua_api.cpp index 755932b..f01658e 100644 --- a/src/text_editor/lua_api.cpp +++ b/src/text_editor/lua_api.cpp @@ -78,7 +78,7 @@ int LuaListOpenBuffers(lua_State *L) { Scratch scratch; Array strings = {scratch}; For(Buffers) { - String string = Format(scratch, "open \"%.*s\"", FmtString(it.name)); + String string = Format(scratch, "%.*s", FmtString(it.name)); Add(&strings, string); } String result = Merge(scratch, strings, "\n"); diff --git a/src/text_editor/text_editor.h b/src/text_editor/text_editor.h index 510c9cf..40a95ab 100644 --- a/src/text_editor/text_editor.h +++ b/src/text_editor/text_editor.h @@ -53,6 +53,10 @@ struct View { int underline_count; Int underline_pos[2]; + + struct { + bool fuzzy_search : 1; + }; }; struct Window { @@ -79,14 +83,12 @@ struct Window { bool draw_scrollbar : 1; bool draw_line_numbers : 1; + bool invisible_when_inactive : 1; bool visible : 1; bool absolute_position : 1; bool is_title_bar : 1; bool is_column : 1; - bool fuzzy_search : 1; // @todo: consider moving this to view and introducing view commands - bool execute_line : 1; - bool invisible_when_inactive : 1; bool dont_save_in_active_window_history : 1; bool deactivate_on_escape : 1; }; diff --git a/src/text_editor/window.cpp b/src/text_editor/window.cpp index b8d2c93..66c0ef9 100644 --- a/src/text_editor/window.cpp +++ b/src/text_editor/window.cpp @@ -164,13 +164,14 @@ void InitWindows(View *null_view) { w->draw_scrollbar = false; w->draw_line_numbers = false; w->visible = false; - w->fuzzy_search = true; w->invisible_when_inactive = true; w->absolute_position = true; w->dont_save_in_active_window_history = true; w->deactivate_on_escape = true; Buffer *b = CreateBuffer(sys_allocator, "*commands*"); View *v = CreateView(b->id); + v->fuzzy_search = true; + SetActiveView(w, v->id); w->z = 1; diff --git a/src/text_editor/window_draw.cpp b/src/text_editor/window_draw.cpp index 6a5ec7b..9e21463 100644 --- a/src/text_editor/window_draw.cpp +++ b/src/text_editor/window_draw.cpp @@ -181,7 +181,7 @@ void DrawWindow(Window *window) { DrawRectOutline(rect, ColorText); } - if (window->fuzzy_search) { + if (view->fuzzy_search) { Caret it = view->carets[0]; Int front = GetFront(it); XY fxy = PosToXY(*buffer, front);