Search all temp buffers opens a new buffer

This commit is contained in:
Krzosa Karol
2026-01-17 08:03:13 +01:00
parent ce1fe5feb1
commit 01488e4eca
3 changed files with 13 additions and 24 deletions

View File

@@ -443,14 +443,14 @@ BSet Open(Window *window, String path, ResolveOpenMeta meta, bool set_active = t
#if PLUGIN_DIRECTORY_NAVIGATION #if PLUGIN_DIRECTORY_NAVIGATION
OpenDirectoryNavigation(view); OpenDirectoryNavigation(view);
#endif #endif
} else { }
Buffer *buffer = GetBuffer(view->active_buffer); Buffer *buffer = GetBuffer(view->active_buffer);
if (o.line != -1) { if (o.line != -1) {
if (o.col == -1) o.col = 1; if (o.col == -1) o.col = 1;
Int pos = XYToPos(buffer, {o.col - 1, o.line - 1}); Int pos = XYToPos(buffer, {o.col - 1, o.line - 1});
SelectRange(view, MakeCaret(pos)); SelectRange(view, MakeCaret(pos));
} }
}
CenterView(window->id); CenterView(window->id);
} else if (o.kind == OpenKind_Exec) { } else if (o.kind == OpenKind_Exec) {
if (set_active) { if (set_active) {

View File

@@ -1,5 +1,3 @@
BufferID SearchOpenBuffersBufferID;
struct SearchOpenBuffersParams { struct SearchOpenBuffersParams {
String16 needle; String16 needle;
BufferID buffer; BufferID buffer;
@@ -78,10 +76,8 @@ void CMD_SearchOpenBuffers() {
} }
NextActiveWindowID = main.window->id; NextActiveWindowID = main.window->id;
Buffer *search_project_buffer = GetBuffer(SearchOpenBuffersBufferID); JumpTempBuffer(&main);
View *view = WindowOpenBufferView(main.window, search_project_buffer->name); AddCommand(&main.view->commands, "Open", "ctrl-q | enter | f12", []() {
view->special = true;
AddCommand(&view->commands, "Open", "ctrl-q | enter | f12", []() {
BSet active = GetBSet(ActiveWindowID); BSet active = GetBSet(ActiveWindowID);
BSet main = GetBSet(PrimaryWindowID); BSet main = GetBSet(PrimaryWindowID);
NextActiveWindowID = main.window->id; NextActiveWindowID = main.window->id;
@@ -90,10 +86,10 @@ void CMD_SearchOpenBuffers() {
main.window->goto_list_pos = active.view->carets[0].range.min; main.window->goto_list_pos = active.view->carets[0].range.min;
Open(string); Open(string);
}); });
view->update_hook = UpdateSearchOpenBuffersView; main.view->update_hook = UpdateSearchOpenBuffersView;
if (string.len) { if (string.len) {
SelectRange(view, GetLineRangeWithoutNL(search_project_buffer, 0)); SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0));
Replace(view, string); Replace(main.view, string);
} }
SelectRange(view, GetLineRangeWithoutNL(search_project_buffer, 0)); SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0));
} RegisterCommand(CMD_SearchOpenBuffers, "ctrl-shift-f", "Interactive search over the entire project in a new buffer view"); } RegisterCommand(CMD_SearchOpenBuffers, "ctrl-shift-f", "Interactive search over the entire project in a new buffer view");

View File

@@ -962,13 +962,6 @@ int main(int argc, char **argv)
EventBuffer->no_history = true; EventBuffer->no_history = true;
EventBuffer->special = true; EventBuffer->special = true;
#endif #endif
#if PLUGIN_SEARCH_OPEN_BUFFERS
Buffer *search_project = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "search_project"));
search_project->no_history = true;
search_project->special = true;
SearchOpenBuffersBufferID = search_project->id;
#endif
} }
InitRender(); InitRender();