Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
905 stars 206 forks source link

Changing variable name vs type can be confusing #3273

Open plafosse opened 2 years ago

plafosse commented 2 years ago

Modal dialogs for change type and change name are not a great solution because once the dialog is up the user looses context of what they triggered the dialog on. Additionally users frequently hit "N" to rename instead of "Y" which allows them to set the type AND name.

Suggestion on how to fix:

  1. Implement a non-modal edit box which appears below the variable/function being renamed/re-typed. This will make it impossible for the user to loose the context of the item they're changing.
  2. Combine the rename and retype features into a single solution. 'N' and 'Y' would both show the name and type. 'N' would have the name selected. 'Y' would have the type selected. But both name and type could be changed.
  3. The thing being changed should be very obvious.
psifertex commented 2 years ago

Rename could be implemented the same way "e" is for inline assembly editing. Let the user edit the token in-place. Change type might not work with that though.

alexrp commented 2 years ago

Note that N allows renaming to e.g. this without using backticks, while Y requires backticks, currently making N more convenient in some cases.

fuzyll commented 2 years ago

3115 is somewhat related. That ticket is related to merging "Change Type" with "Edit Function Properties" because the latter has options that need to be more discoverable. (Hitting y would bring up that window, but with the function prototype being editable and your cursor in the box so that y -> <editing> -> Enter is still preserved as a workflow.)

Also, I'm not sure combining n and y is a good idea. You can rename things that aren't functions (e.g. variables), some of which don't have a type (e.g. labels). If we have a way around that and still want to do a unified interface, I would still argue for the n hotkey to remain and automatically allow the name to be quickly edited to preserve the very fast n -> <edit name> -> Enter workflow, which is used a lot.

I think I would personally prefer option 1 from above for rename (e.g. eliminating the extra window altogether in favor of a non-modal edit box) and then implementing #3115. This is an example from VSCode of the former:

image

plafosse commented 2 years ago

Some furious internal discussion prompted this picture which most people seemed to like better than my text description above 😅 IMG_4994

plafosse commented 2 years ago

So these are some of the things I’ve seen people do in the user studies:

The goal in a non-modal unification is to:

Also potential solutions. Add a new "SHIFT + Y" command to "Change Type Only". Which would allow but then ignore the variable name if typed.

alexrp commented 2 years ago

Some furious internal discussion prompted this picture which most people seemed to like better than my text description above 😅

Couple of questions:

  1. How would this pre-selection work with complex types like arrays and function pointers?
  2. What happens if you press Y and erase the whole line and write only a type? (This is something that works today.)
plafosse commented 2 years ago
  1. Good question, thats something I hadn't thought of. Likely you'd have to highlight the whole thing if you hit Y. But you could highlight just name name if you hit N.
  2. It would work just like it already does.
op2786 commented 1 year ago

Some furious internal discussion prompted this picture which most people seemed to like better than my text description above 😅 IMG_4994

I couldn't help but comment that this looks great!