From 6e5a18e7f825acf746d1564ffa9ceee0a9e95a6c Mon Sep 17 00:00:00 2001 From: fundon Date: Sat, 7 Feb 2015 02:44:04 +0800 Subject: [PATCH] use specific disposable for commands, fix disable/enable minimap-element attach bug --- lib/main.coffee | 18 +++++++++++------- lib/minimap-element.coffee | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/main.coffee b/lib/main.coffee index 94932161..af751356 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -89,17 +89,21 @@ class Main # Internal: Used only at export time. constructor: -> @emitter = new Emitter + + # Commands Subscriptions + @subscriptionsOfCommands = new CompositeDisposable + @subscriptionsOfCommands.add atom.commands.add 'atom-workspace', + 'minimap:toggle': => @toggle() + 'minimap:generate-plugin': => @generatePlugin() + + # Other Subscriptions @subscriptions = new CompositeDisposable - # Activates the minimap package. - activate: -> MinimapElement ?= require './minimap-element' - MinimapElement.registerViewProvider() - @subscriptions.add atom.commands.add 'atom-workspace', - 'minimap:toggle': => @toggle() - 'minimap:generate-plugin': => @generatePlugin() + # Activates the minimap package. + activate: -> @toggle() if atom.config.get 'minimap.autoToggle' @@ -132,7 +136,7 @@ class Main @editorsMinimaps?.forEach (value, key) => value.destroy() @editorsMinimaps.delete(key) - @editorsMinimaps = undefined + @subscriptions.dispose() else @toggled = true @initSubscriptions() diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index 71ea805c..e366a643 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -93,6 +93,7 @@ class MinimapElement extends HTMLElement attach: -> return if @attached @swapMinimapPosition() + @attached = true attachToLeft: -> root = @getTextEditorElementRoot()