Alternative to NPPM_REMOVESHORTCUTBYCMDID is required
-
I was thinking about this subject again and again, and here is my conclusion: the proposed approach with NPPM_REMOVESHORTCUTBYCMDID is a completely wrong direction.
Here is why.
The source of a problem is not in plugins, it’s in Notepad++ itself. Here is what I mean: the origin, the cause of the problem comes from the way how Notepad++ stores shortcuts for the plugins. Notepad++ maps the shortcut keys to the value of internalID that is not e.g. a unique hash of plugin’s menu item name, but something like a menu item’s position. Obviously, when this position is changed, the mappings between these positions and shortcuts becomes wrong.
Now I’m asking a question: is it a plugin’s fault? What if Notepad++ stored some unique hash keys to identify plugin’s menu items disregarding the menu items’ positions, would we face this problem?
And, by introducing NPPM_REMOVESHORTCUTBYCMDID , aren’t we in fact trying to fix Notepad++‘es internal issue in an external plugin’s code? Isn’t it strange?
Moreover, anyway some different fix is needed to deal with moving (reordering) of menu items. Let me illustrate it by example. Let’s say we have the following scripts’ menu items created by NppExec with the following shortcuts assigned via the Shortcut Mapper:Script A - Shortcut A
Script B - Shortcut B
Script C - Shortcut CNow let’s assume we have reordered these items and added a new one by means of NppExec. This is how Notepad++ assigns the shortcuts to the reordered items:
Script C - Shortcut A
Script D (new one) - Shortcut B
Script A - Shortcut C
Script B - no shortcutThis is completely wrong and has no chance to be fixed by NPPM_REMOVESHORTCUTBYCMDID, so another one additional “fix” is needed… or -
So my proposal is to fix this issue in Notepad++ itself: do it once - and for all the existing and future plugins.
-
A unique hash of the plugin’s menu item name wouldn’t work too. What if a user renames a script’s menu entry?
-
Yes, it’s one of possible problems. Though we can treat a renamed item as a combination of deletion and creation of a new item, so it’s OK for shortcut to disappear :)
Another big problem with hashing menu items names will appear if a plugin supports different languages in its interface. In such case, different language will lead to completely different item names. Though, in case of menu items added by user it should not be a problem - since these items are added by user who fully controls the item names. But the problem with renaming of a menu item (after a shortcut has already been asdigned) still remanis.
Maybe it would be worth to add some kind of Menu Items Manager to Notepad++'s plugin interface to deal with custom menu items created and modified by plugins.