Hide commands from command palette
klorenz opened this issue · 8 comments
I have created package https://atom.io/packages/character-table which enables vim-like digraph support. For each key to insert, there has to be created a command to bind it to a character-specific key sequence. If digraph mode enabled this adds ~1800 commands and this slows down the behaviour of command palette.
I would like to hide these commands from command palette or it should be possible
to set a limit of displayed commands.
E.g. you could hide all "-my-package:hidden-command" commands or "hidden:my-package:my command" or ":my-package:my-command" or whatever.
👍 This would also be helpful for me. I am trying to create a context menu command that does something based on the mouse position obtained from a mouse-down event. This works fine, but I have to have to set up a command handler for the context menu. The command only works if triggered from the context menu because that's when I can capture the mouse-down event. If you try to trigger the command from the command palette, it doesn't make any sense. There's no mouse-down event for me to use, so I just have to ignore it. Ideally I could just remove those commands from the command palette, since they only make sense as context menu items.
👍
So in order to do what is proposed (filter out by a prefix in the commandName), we'd need to filter when we set the items here. A simple
[{name:':name:asdf'}, {name: 'name2:asdf'}].filter(function(command){return !command.name.startsWith(':')})
commands = commands.filter (command) -> not command.name.startsWith(':')
The hard part is deciding a valid, backwards compatible prefix, that CommandRegistry.add(...) accepts. Note that it calls _.humanizeEventName() which calls [namespace, event] = eventName.split(':')
. I need to check that having more than one :
in the eventName
will not raise an error.
I would love to see some user config files or options to control the command palette for packages as well, or even specific commands. Currently using git plus, and the recent update to atom's git support has added a slew of annoying "github:" commands that constantly show up above the commands I use every day, and mess with my muscle memory.
I'd also be interested in having a command palette hide function. Even if it is just a command to use in the init file of atom. Personally, I love atom/github's staging design, but I use Bitbucket Server (Atlassian Stash) at work, which does not work with atom/github's command palette.
You can hide them from display using stylesheets:
.command-palette {
li[data-event-name="multi-wrap-guide:remove-guide"],
li[data-event-name="multi-wrap-guide:create-vertical-guide"],
li[data-event-name="multi-wrap-guide:create-horizontal-guide"],
li[data-event-name="multi-wrap-guide:create-horizontal-guide"]
{
display: none !important;
}
}
However when navigating the Command Palette with the keyboard you can still navigate to these hidden elements... which, come to think of it, seems like a bug in either atom-select-list
or atom-command-palette
.
Also I'm not sure you'd get much of a performance gain using stylesheets to filter items out of the list if your package is adding a boat load of items to the darn thing. 🤔
@lexicalunit Thank you! I attempted to do something similar to this, but the command palette was re-initiating them into the list. This works for what I needed it to do, but does not fix the the OP's issue.
This would also help with vim-mode-plus
.
40% of all registered commands come from vmp in my case:
Object.keys(atom.commands.getSnapshot()).filter(name => name.match(/vim-mode-plus:/)).length / Object.keys(atom.commands.getSnapshot()).length
0.4038095238095238
That is 424/1050. There is a significant delay when typing.