Skip to content

Fix scroll reset when renaming variables in DecompilerWidget - #3648

Open
andersendsa wants to merge 1 commit into
rizinorg:devfrom
andersendsa:scroll_reset
Open

Fix scroll reset when renaming variables in DecompilerWidget#3648
andersendsa wants to merge 1 commit into
rizinorg:devfrom
andersendsa:scroll_reset

Conversation

@andersendsa

Copy link
Copy Markdown
Contributor

This commit updates the active history index with the current scrollbar positions immediately prior to initiating a new decompilation request.

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've updated the documentation with the relevant information (if needed)
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description
When renaming variables, doRefresh() was triggered without updating the scrollHistory with the current position. This caused decompilationFinished() to restore the scroll bar to the position of the last explicit seek, effectively resetting the scroll position.

Test plan (required)

  1. Load a Binary: Open Cutter and load any standard executable or binary file. Let the initial analysis complete.
  2. Open Decompiler: Navigate to the Decompiler widget (Windows -> Decompiler or select the Decompiler tab).
  3. Find a Large Function: Seek to a function that is long enough to require vertical scrolling in the decompilation window. You can find one easily via the Functions widget.
  4. Scroll Down: Scroll down to the middle or bottom of the function's decompiled code, so that the top of the function is completely out of view.
  5. Rename a Variable: Right-click on any variable name visible in your current viewport and select "Rename..." (or use the shortcut Shift+N).
  6. Apply Rename: Enter a new name for the variable and press Enter to confirm.
  7. Verify Outcome: Observe the decompiler window. The text should briefly show a loading state and then display the newly decompiled code with the updated variable name. Crucially, the scrollbar position should remain exactly where you left it, rather than jumping back up to the top of the function or the last explicit seek position.

Closing issues
Closes:#3643

@andersendsa

Copy link
Copy Markdown
Contributor Author

Hi @PremadeS could you pls let me know if the pr needs any changes or if it is good to merge ?

@PremadeS

Copy link
Copy Markdown
Collaborator

It works, although whenever I scroll the decompiler viewport to the end of a long function (X) and immediately seek to the starting of a different function (Y) (from the functions widget), it scrolls to the ending of "Y" even though it should the start of "Y" as the current seek is there. This makes sense with the current implementation because you're restoring the scrollbar position before every refresh

Not a dead breaker however it would be nice to show the decompiled output from the start when seeking to the start of a completely different function :)

Note that this only happens if the seek is at the start of the function, seeking to anywhere inside the function works fine

@andersendsa

Copy link
Copy Markdown
Contributor Author

Hi @PremadeS I have done the changes pls let me know if there are any other changes needed or if it is good to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants