From 9c99e5db7a3c6a1d294f8f3e56fe5de654110699 Mon Sep 17 00:00:00 2001 From: blasty Date: Sat, 25 Jul 2026 15:06:19 +0200 Subject: projects: open the Ctrl+O switcher on the binary you're already in It always highlighted row 0, so switching away and back meant hunting for your current position in the list. Preselect the entry marked active instead; if a filter excludes it, fall back to the first row as before. Locked in test_project_ui.py (21 checks). --- idatui/app.py | 5 ++++- tests/test_project_ui.py | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/idatui/app.py b/idatui/app.py index f9ddfea..9ef0c47 100644 --- a/idatui/app.py +++ b/idatui/app.py @@ -2474,7 +2474,10 @@ class ProjectPalette(ModalScreen): opts.append(Option(label)) ol.add_options(opts) if rows: - ol.highlighted = 0 + # Land on the binary you're already in, so the switcher opens where + # you are rather than at whatever sorts first. + active = next((i for i, e in enumerate(rows) if e["active"]), 0) + ol.highlighted = active self.query_one("#pal-title", Static).update( f" binaries: {len(rows)} of {len(self._entries)}") diff --git a/tests/test_project_ui.py b/tests/test_project_ui.py index 8a0fd2b..e3bfb62 100644 --- a/tests/test_project_ui.py +++ b/tests/test_project_ui.py @@ -18,7 +18,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from idatui._sync import wait_for # noqa: E402 from idatui.app import IdaTui, ProjectPalette # noqa: E402 from idatui.project import Project # noqa: E402 -from textual.widgets import Input, Static # noqa: E402 +from textual.widgets import Input, OptionList, Static # noqa: E402 PASS = FAIL = 0 @@ -82,6 +82,13 @@ async def run(bins): check("it marks the other as not yet opened", any(not e["resident"] and e["label"] == second for e in pal._results)) + ol = pal.query_one(OptionList) + check("the switcher opens on the binary you're already in", + ol.highlighted is not None + and pal._results[ol.highlighted]["label"] == first, + f"highlighted={ol.highlighted} " + f"={pal._results[ol.highlighted]['label'] if ol.highlighted is not None else None} " + f"want={first}") # -- switch to the second binary -------------------------------- # pal.query_one(Input).value = second -- cgit v1.3.1-sl0p