From ba6de21396651c7c0c07a82627f0d44e2b9c5e06 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 23 Jan 2026 22:36:11 +0100 Subject: [PATCH] Query file add UI indicator (but need something better ...), fix remedy --- src/text_editor/plugin_remedybg.cpp | 92 +++++++++++++++-------------- src/text_editor/ui.cpp | 3 + 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/src/text_editor/plugin_remedybg.cpp b/src/text_editor/plugin_remedybg.cpp index 4b13fa9..714faf3 100644 --- a/src/text_editor/plugin_remedybg.cpp +++ b/src/text_editor/plugin_remedybg.cpp @@ -2108,6 +2108,31 @@ bool RDBG_InitConnection(mco_coro *co, bool create_session = true) { } } + String file = ""; + if (create_session) { + if (BinaryUnderDebug.len) { + Window *window = GetWindow(PrimaryWindowID); + ResolvedOpen res = ResolveOpen(CoCurr->arena, window, BinaryUnderDebug, ResolveOpenMeta_DontError | ResolveOpenMeta_DontExec); + if (res.kind == OpenKind_Goto) { + file = Intern(&GlobalInternTable, res.path); + } + } + + if (file.len == 0) { + Scratch scratch; + for (FileIter it = IterateFiles(scratch, ProjectDirectory); IsValid(it); Advance(&it)) { + if (EndsWith(it.filename, ".rdbg")) { + file = Intern(&GlobalInternTable, it.absolute_path); + break; + } + } + } + + if (file.len == 0) { + file = QueryUserFile(co); + } + } + String session_name = Format(CoCurr->arena, "te%llu", GetTimeNanos()); String remedy_string = Format(CoCurr->arena, "%S --servername %S", RemedyBGPath, session_name); ReportConsolef("Remedybg: %S", remedy_string); @@ -2137,56 +2162,33 @@ bool RDBG_InitConnection(mco_coro *co, bool create_session = true) { } MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); - if (create_session == false) { - return true; - } + if (create_session) { + if (EndsWith(file, ".rdbg")) { + ReportConsolef("Remedybg: OpenSession %S", file); + OpenSession(&RDBG_Ctx, file.data, &res); + } else { + ReportConsolef("Remedybg: CreateSession %S", file); + rdbg_Id cfg_id; + char *exe = file.data; + char *args = NULL; + char *work_dir = ProjectDirectory.data; + char *env = NULL; + AddSessionConfig(&RDBG_Ctx, exe, args, work_dir, env, true, true, &res, &cfg_id); + if (ContextHadError(&RDBG_Ctx)) { + ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error); + MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); + return true; + } - String file = ""; - if (BinaryUnderDebug.len) { - Window *window = GetWindow(PrimaryWindowID); - ResolvedOpen res = ResolveOpen(CoCurr->arena, window, BinaryUnderDebug, ResolveOpenMeta_DontError | ResolveOpenMeta_DontExec); - if (res.kind == OpenKind_Goto) { - file = Intern(&GlobalInternTable, res.path); - } - } - - if (file.len == 0) { - Scratch scratch; - for (FileIter it = IterateFiles(scratch, ProjectDirectory); IsValid(it); Advance(&it)) { - if (EndsWith(it.filename, ".rdbg")) { - file = Intern(&GlobalInternTable, it.absolute_path); + SetActiveSessionConfig(&RDBG_Ctx, cfg_id, &res); + if (ContextHadError(&RDBG_Ctx)) { + ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error); + MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); + return true; } } } - if (file.len == 0) { - file = QueryUserFile(co); - } - - if (EndsWith(file, ".rdbg")) { - ReportConsolef("Remedybg: OpenSession %S", file); - OpenSession(&RDBG_Ctx, file.data, &res); - } else { - ReportConsolef("Remedybg: CreateSession %S", file); - rdbg_Id cfg_id; - char *exe = file.data; - char *args = NULL; - char *work_dir = ProjectDirectory.data; - char *env = NULL; - AddSessionConfig(&RDBG_Ctx, exe, args, work_dir, env, true, true, &res, &cfg_id); - if (ContextHadError(&RDBG_Ctx)) { - ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error); - MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); - return true; - } - - SetActiveSessionConfig(&RDBG_Ctx, cfg_id, &res); - if (ContextHadError(&RDBG_Ctx)) { - ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error); - MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); - return true; - } - } return true; } diff --git a/src/text_editor/ui.cpp b/src/text_editor/ui.cpp index 9ed87f1..0a9e389 100644 --- a/src/text_editor/ui.cpp +++ b/src/text_editor/ui.cpp @@ -152,6 +152,9 @@ String QueryUserFile(mco_coro *co) { Window *window = GetWindow(PrimaryWindowID); ViewID original_view = window->active_view; Open(GetPrimaryDirectory()); + BSet set = GetBSet(window); + RawReplaceText(set.buffer, {}, u"Point at a file you want to open!"); + SelectRange(set.view, GetLineRangeWithoutNL(set.buffer, 0)); window->after_resolve_open_hook = DetectUserFileCallback; String filename = ""; for (;;) {