Keymap selector specificity not working as expected (Update: solved)


#1

I read that CSS specificity will determine precedence when executing keybindings, but it doesn’t seem to be working as I would expect.

Basically: I want to be able to run github:commit when pressing the enter key in the github commit message editor. At first, my keybinding looked like this:

'.github-CommitView-editor':
    'enter': 'github:commit'

This didn’t work, so I opened up the Keybinding Resolver to see what was happening. My command had been matched (it was #2 in the list) but only editor:newline (#1) was highlighted in green.

At this point I’m like “oh right, specificity.” The editor:newline command was being triggered within the selector atom-text-editor:not([mini]). So I changed my keybinding to incorporate that selector:

'atom-text-editor:not([mini]) .github-CommitView-editor':
    'enter': 'github:commit'

Feeling confident, I tried it again, but it still didn’t work. I checked the Keybinding Resolver, only to find that my keymapping was now at the bottom of the list and was grayed out with an X… the exact opposite of what I was expecting.

What am I getting wrong here? Why did increasing specificity seem to decrease the precedence of my custom keymapping? Am I specifying the action wrong?


Edit: I’m dumb… I thought atom-text-editor was a high-level parent element, but in this instance it’s actually a child of the commit editor (which makes sense, since you’re editing text). My 2nd attempt didn’t match at all because the selectors were reversed. Here’s the selector that worked:

'.github-CommitView-editor atom-text-editor':
    'enter': 'github:commit'