mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Ctrl-enter toggles event palette (hides when showing)
I changed the event name to event-palette:toggle because ctrl-enter should hide the event palette when it is showing. Previously that broke, because we would try to re-show the event palette.
This commit is contained in:
@@ -11,12 +11,12 @@ describe "EventPalette", ->
|
||||
rootView.activateExtension(EventPalette)
|
||||
palette = EventPalette.instance
|
||||
rootView.attachToDom().focus()
|
||||
rootView.trigger 'event-palette:show'
|
||||
rootView.trigger 'event-palette:toggle'
|
||||
|
||||
afterEach ->
|
||||
rootView.remove()
|
||||
|
||||
describe "when event-palette:show is triggered on the root view", ->
|
||||
describe "when event-palette:toggle is triggered on the root view", ->
|
||||
it "shows a list of all valid events for the previously focused element, then focuses the mini-editor and selects the first event", ->
|
||||
for [event, description] in rootView.getActiveEditor().events()
|
||||
expect(palette.list.find(".event:contains(#{event})")).toExist()
|
||||
@@ -24,6 +24,13 @@ describe "EventPalette", ->
|
||||
expect(palette.miniEditor.isFocused).toBeTruthy()
|
||||
expect(palette.find('.event:first')).toHaveClass 'selected'
|
||||
|
||||
describe "when event-palette:toggle is triggered on the open event palette", ->
|
||||
it "focus the root view and detaches the event palette", ->
|
||||
expect(palette.hasParent()).toBeTruthy()
|
||||
palette.trigger 'event-palette:toggle'
|
||||
expect(palette.hasParent()).toBeFalsy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe "when the event palette is cancelled", ->
|
||||
it "focuses the root view and detaches the event palette", ->
|
||||
expect(palette.hasParent()).toBeTruthy()
|
||||
|
||||
@@ -8,7 +8,7 @@ class EventPalette extends SelectList
|
||||
@activate: (rootView) ->
|
||||
requireStylesheet 'event-palette/event-palette.css'
|
||||
@instance = new EventPalette(rootView)
|
||||
rootView.on 'event-palette:show', => @instance.attach()
|
||||
rootView.on 'event-palette:toggle', => @instance.attach()
|
||||
|
||||
@viewClass: ->
|
||||
"#{super} event-palette"
|
||||
@@ -16,6 +16,7 @@ class EventPalette extends SelectList
|
||||
filterKey: 0 # filter on the event name for now
|
||||
|
||||
initialize: (@rootView) ->
|
||||
@on 'event-palette:toggle', => @cancel()
|
||||
super
|
||||
|
||||
attach: ->
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
window.keymap.bindKeys 'body'
|
||||
'ctrl-enter': 'event-palette:show'
|
||||
window.keymap.bindKeys 'body, .event-palette .editor'
|
||||
'ctrl-enter': 'event-palette:toggle'
|
||||
|
||||
window.keymap.bindKeys '.event-palette .editor'
|
||||
'enter': 'event-palette:select'
|
||||
'escape': 'event-palette:cancel'
|
||||
'ctrl-enter': 'event-palette:toggle'
|
||||
|
||||
Reference in New Issue
Block a user