microsoft / RTVS

R Tools for Visual Studio.
MIT License
390 stars 118 forks source link

In Variable Explorer, delete is appearing in context menu where it shouldn't #4254

Open arencambre opened 6 years ago

arencambre commented 6 years ago

In the Variable Explorer pane, it appears the delete option shows in any context menu. That is, I can right-click on any item in the Variable Explorer, and a rm command is issued using the value in the selected item's Name field in the Variable Explorer. What this means is if you attempt to delete any component (child item?) of something in Variable Explorer, such as a column in a dataframe, Visual Studio tries to delete a variable of the same name.

For example, suppose you have a dataframe y with column x. Let's also suppose you have an integer variable named x. If you expand the dataframe y and delete its column x by right-clicking on it, Visual Studio issues a rm command to delete something named x, which will delete the integer variable, not the dataframe column!

Yes, I realize you may not have intended for me to be able to delete a column from a data frame, but the UI is informing me otherwise.

Expected behavior: The delete option should only be displayed when a context menu is invoked of something that is actually delete-able. Clearly, it is not possible to delete a column of a dataframe through that context menu of a dataframe, so the delete options should not show there.

MikhailArkhipov commented 6 years ago

This is currently by design as it is too expensive to check command applicability on UI updates. But there is probably issue in the fact that rm gets variable name rather than full name of the dataframe member, i.e rm df$x which will fail but at least safely.

arencambre commented 6 years ago

Thank you. A safe fail would be an improvement.