Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

More specific selector doesn't override less specific #138

Open
tomasbedrich opened this issue Aug 13, 2016 · 6 comments
Open

More specific selector doesn't override less specific #138

tomasbedrich opened this issue Aug 13, 2016 · 6 comments

Comments

@tomasbedrich
Copy link

I have following code in my keymap:

'atom-workspace atom-text-editor[data-grammar~="html"]:not([mini])':
  'cmd-/': 'emmet:toggle-comment'

The Keybindings settings:

keybindings settings

I would expect my User selector should override the less specific Core selector when editing HTML, however the Core keystroke is used when pressing Ctrl-/.

BTW: When I change my selector to be exactly same as Core, it works well. But I want to use the emmet:toggle-comment command only for HTML.

@mauricioszabo
Copy link

I've got another way of simulating this: using proto-repl, it'll create an Ink Console when I toggle the plugin. I posted about it in this discussion:

https://discuss.atom.io/t/why-do-user-key-bindings-not-take-priority/11740/7?u=mauricioszabo

Steps to reproduce

  • Install proto-repl
  • Run command "Proto Repl: Toggle" (it'll open a console). Probably will open even if you don't have a Clojure env installed)
  • Try to unset the "pageup" or "pagedown" key, in the console, so that it'll not be captured by Atom.

I've tried two ways of unsetting the pageup:

'ink-console atom-text-editor':
  'pageup': 'unset!'

'body ink-console atom-text-editor':
  'pageup': 'unset!'

'ink-console atom-text-editor:not(.mini)':
  'pageup': 'unset!'

None of the above worked - pageup keeps being captured by body selector (Atom's default)

The strange thing is that if I try to bind to any other thing, other than "unset", it works.

/cc @lee-dohm

@mauricioszabo
Copy link

Other strange thing: one of my keybindings (in the editor) is ctrl-q. The problem is that sometimes, Atom just ignores my keybind and just uses its default, which is... to quit the editor 😞

The following bindings didn't override its defaults:

'body':
    'ctrl-q': 'unset!' # atom understands it, shows on keybinding resolver, but sometimes, ignores it
    'ctrl-q': 'tree-view:toggle' # don't work
    'ctrl-q': 'application:open-file' # don't work either

Now, this is some serious issue - I can't have to sometimes understand my keybindings, and sometimes, not, specially if one of them causes all my open Atom instances to quit. I don't even understand why there's a keybinding for "quit all open atom windows in all namespaces and all projects" in the first place...

@winstliu
Copy link
Contributor

Ctrl+Q, at least for me, doesn't exist on Windows - what OS are you using?

@mauricioszabo
Copy link

Arch Linux, but the same happens on Ubuntu 14.10 and 16

@winstliu
Copy link
Contributor

Can you try not unsetting it, like in the following example? I tried it out with ctrl-w which seems to be working.

'body':
  'ctrl-q': 'tree-view:toggle'

@mauricioszabo
Copy link

I did a little debugging on this, and found out I was separating keybindings on some sections - all Clojure files should use these keybindings, all ruby, these other, etc.

I found out I had two body clauses, and Atom was ignoring the first. So, probably this case will not happen so often anymore, but still this means I need to disable keybindings in the same selector (and hope that Atom captures the correct one - for example, when I need to upgrade a plugin, I need to restart Atom otherwise the plugin's keybindings overrides mine when it reloads...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants