From f0fbe44250cb0c106e106f360db171f77912f8e4 Mon Sep 17 00:00:00 2001 From: abe33 Date: Fri, 13 Feb 2015 19:37:47 +0100 Subject: [PATCH] :bug: Fix code highlight not toggled with keyboard in quick settings --- lib/minimap-quick-settings-element.coffee | 10 ++++++++-- spec/minimap-element-spec.coffee | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/minimap-quick-settings-element.coffee b/lib/minimap-quick-settings-element.coffee index 518a38a2..72bd9f5d 100644 --- a/lib/minimap-quick-settings-element.coffee +++ b/lib/minimap-quick-settings-element.coffee @@ -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}) => @@ -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) => @@ -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) @@ -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 diff --git a/spec/minimap-element-spec.coffee b/spec/minimap-element-spec.coffee index 5c07eaf6..a485748c 100644 --- a/spec/minimap-element-spec.coffee +++ b/spec/minimap-element-spec.coffee @@ -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'