binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

Changing variable name vs type can be confusing

Open plafosse opened this issue 3 years ago • 7 comments

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.

plafosse avatar Jul 11 '22 15:07 plafosse

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.

psifertex avatar Jul 11 '22 15:07 psifertex

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

alexrp avatar Jul 11 '22 17:07 alexrp

#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

fuzyll avatar Jul 11 '22 18:07 fuzyll

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

plafosse avatar Jul 11 '22 19:07 plafosse

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

  • People thinking they’re changing one thing but changing something else (once the modal pops up its not clear what the thing you’re changing is)
  • People thinking they’re changing the type but instead renaming with a type (its not obvious enough what you’re doing in the modal dialog)
  • People clicking ‘y’ but meaning to type ‘Y’ instead.

The goal in a non-modal unification is to:

  • Make it very explicit what you’re changing. You can’t confuse N/Y because its always the same thing. Most people don’t change the name and the type at the same time. (Additionally if we like we could make Y select the whole thing instead of just the type)
  • Keep around the text that you’re changing from. This would make it abundantly clear what you’re changing it from and what you’re changing it to.
  • Allow copying and pasting from other stuff while the edit control is displayed.

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

plafosse avatar Jul 11 '22 19:07 plafosse

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.)

alexrp avatar Jul 11 '22 19:07 alexrp

  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.

plafosse avatar Jul 11 '22 19:07 plafosse

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!

op2786 avatar Mar 23 '23 12:03 op2786