Skip to content

Commit

Permalink
🐛 Fix code highlight not toggled with keyboard in quick settings
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Feb 13, 2015
1 parent 170418c commit f0fbe44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/minimap-quick-settings-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class MinimapQuickSettingsElement extends HTMLElement
@emitter = new Emitter
@subscriptions = new CompositeDisposable
@plugins = {}
@itemsActions = new WeakMap

@subscriptions.add Main.onDidAddPlugin ({name, plugin}) =>
@addItemFor(name, plugin)
@subscriptions.add Main.onDidRemovePlugin ({name, plugin}) =>
Expand All @@ -46,7 +48,9 @@ class MinimapQuickSettingsElement extends HTMLElement
'mousedown': (e) =>
e.preventDefault()
atom.config.set('minimap.displayCodeHighlights', !@minimap.displayCodeHighlights)
@codeHighlights.classList.toggle('active', @minimap.displayCodeHighlights)

@itemsActions.set @codeHighlights, =>
atom.config.set('minimap.displayCodeHighlights', !@minimap.displayCodeHighlights)

@subscriptions.add @subscribeTo @hiddenInput,
'focusout': (e) =>
Expand All @@ -62,6 +66,9 @@ class MinimapQuickSettingsElement extends HTMLElement
e.preventDefault()
atom.config.set('minimap.displayMinimapOnLeft', false)

@subscriptions.add atom.config.observe 'minimap.displayCodeHighlights', (bool) =>
@codeHighlights.classList.toggle('active', bool)

@subscriptions.add atom.config.observe 'minimap.displayMinimapOnLeft', (bool) =>
@onLeftButton.classList.toggle('selected', bool)
@onRightButton.classList.toggle('selected', not bool)
Expand All @@ -82,7 +89,6 @@ class MinimapQuickSettingsElement extends HTMLElement
@parentNode.removeChild(this)

initList: ->
@itemsActions = new WeakMap
@itemsDisposables = new WeakMap
@addItemFor(name, plugin) for name, plugin of Main.plugins

Expand Down
9 changes: 9 additions & 0 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,15 @@ describe 'MinimapElement', ->
it 'enable the plugin of the selected item', ->
expect(pluginA.isActive()).toBeTruthy()

describe 'on the code highlight item', ->
beforeEach ->
atom.commands.dispatch quickSettingsElement, 'core:move-down'
atom.commands.dispatch quickSettingsElement, 'core:move-down'
atom.commands.dispatch quickSettingsElement, 'core:confirm'

it 'toggles the code highlights on the minimap element', ->
expect(minimapElement.displayCodeHighlights).toBeFalsy()

describe 'core:move-down', ->
beforeEach ->
atom.commands.dispatch quickSettingsElement, 'core:move-down'
Expand Down

0 comments on commit f0fbe44

Please sign in to comment.