Closed panoskj closed 1 year ago
I think you have done an excellent job. The command keybindings using the vscode context variables is very impresive and the handling of multiple item selection commands very promising.
Thanks for the positive feedback! I made some slight optimizations/changes regarding how multiple items are deleted.
If the user has selected multiple categories/groups of tree items (e.g. some files and some package references) there is no need to construct their deletion actions (since they won't be executed). As an optimization, I moved the construction of these actions after the check.
Added check for the edge case when the user manually executes the delete command while having selected tree items that should not be delete-able. I forgot to mention it earlier, but a side effect of this PR is that the user can execute any command without having to pass the tree item as an argument (they can simply select the item(s) in the tree and commands will work).
Disabled deleting multiple package/project references, when both CPS and standard references are selected (this is possible, because there is no checking whether these references are across multiple projects). Otherwise, CPS references would be deleted successfully leaving standard references intact. I think this could be misleading.
Renamed ActionsCommand to SingleItemActionsCommand and ActionsBaseCommand to ActionsCommand. I think these names make more sense now.
As we discussed in #253 I was going to try merging commands that are activated by the same keybinding. This would work, but the merged commands' menu items would also share the same name (for example "Remove Reference" would become "Delete"). So I took a step back and tried another approach.
The first commit of this PR simply prepares the ground for the next one.
The second commit enables keybindings. Notice the added "multiple-selection" context value, which ensures existing keybindings will not run when multiple items are selected.
The third commit adds an implementation for handling deletion of multiple items at once.
VS IDE works in the same way too. Also note that the clicked item is not necessarily one of the selected items - you can right click and execute a command on an item that is not selected at all, in which case the selected items should be ignored.
There are more commands that can be executed for multiple selected items (e.g. copy, compile, build, etc). As for the "copy" command though, I think there is a bug in its "paste" counterpart anyway, preventing it from working properly (you can paste a folder but not a file).
Finally, it seems possible to define menus that only appear in case multiple items are clicked. For example, when you right click on multiple folder items, the options to "create a file/folder", "paste" and "rename" shouldn't appear at all. Or when you right click on a project and a folder that is inside it, you should only get the option to delete them. VS IDE does this too. I may make a proof of concept after getting this PR merged.
So, let me know what you think about this PR for a start. I didn't like the terse syntax I used in some places for one, but I didn't like the alternatives either.