From d7003527f15398e8bed4227c07302489c650fa2b Mon Sep 17 00:00:00 2001 From: blasty Date: Thu, 9 Jul 2026 21:18:24 +0200 Subject: decompiler: xref jump within the current function moves the cursor The earlier xref->pseudocode-line fix only worked when the jump target was in a DIFFERENT function (which reloads the pane). When the target was inside the function already displayed, _show_active skipped the reload -> and never applied the new dec_cursor, so the cursor stayed put (the reported 'jumping to xref in decompile view doesn't work'; most xrefs land in the shown function). _open_entry now detects the already-loaded case and repositions the decompiler via a new DecompView.goto (moves cursor/scroll on the loaded text, no re-highlight). Toggle (Tab) still goes through _show_active untouched. Add a same-function xref-jump pilot check. full suite 64/64. --- tests/test_tui.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/test_tui.py b/tests/test_tui.py index 2f80270..1641368 100644 --- a/tests/test_tui.py +++ b/tests/test_tui.py @@ -383,6 +383,25 @@ async def run(db): await pilot.pause(0.1) check("xref-select lands on the reference LINE in pseudocode", dec.cursor == dexp, f"dec.cursor={dec.cursor} want={dexp}") + + # And a jump whose target is INSIDE the already-displayed + # function must still move the cursor (the decompiler pane + # isn't reloaded in that case, so it needs explicit repos). + anch = [(i, dec._line_ea(i)) for i in range(len(dec._texts)) + if dec._line_ea(i) is not None] + if len(anch) >= 4: + start_ln = anch[1][0] + far_ea = anch[len(anch) // 2][1] + exp2 = app._decomp_line_for(app._cur.ea, far_ea) + dec.focus() + dec.cursor = start_ln + dec.refresh() + await pilot.pause(0.05) + app._on_xref_chosen(far_ea) # target within this function + await wait_until(pilot, lambda: dec.cursor == exp2, timeout=20) + check("xref-select moves the cursor within the same function", + dec.cursor == exp2 and exp2 != start_ln, + f"dec.cursor={dec.cursor} want={exp2} start={start_ln}") app._active = "disasm" # restore for the following blocks app._show_active() await pilot.pause(0.05) -- cgit v1.3.1-sl0p