diff options
| -rw-r--r-- | idatui/app.py | 5 | ||||
| -rw-r--r-- | 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 |
