From 94251a2fad79594533a5627506ea6af95d4e311d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 23 Jul 2012 19:10:07 -0600 Subject: [PATCH] Only store operations to preview on the PreviewList --- .../command-panel/command-panel.coffee | 16 ++++++---------- src/extensions/command-panel/preview-list.coffee | 3 +++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/extensions/command-panel/command-panel.coffee b/src/extensions/command-panel/command-panel.coffee index b8054f374..452199d2b 100644 --- a/src/extensions/command-panel/command-panel.coffee +++ b/src/extensions/command-panel/command-panel.coffee @@ -18,7 +18,7 @@ class CommandPanel extends View @instance = new CommandPanel(rootView) @deactivate: -> - @instance.detach() + @instance.destroy() @serialize: -> text: @instance.miniEditor.getText() @@ -60,6 +60,9 @@ class CommandPanel extends View @previewList.hide() + destroy: -> + @previewList.destroy() + toggle: -> if @miniEditor.isFocused @detach() @@ -89,9 +92,6 @@ class CommandPanel extends View detach: -> @rootView.focus() @previewList.hide() - if @previewedOperations - operation.destroy() for operation in @previewedOperations - @previewedOperations = undefined super execute: (command = @miniEditor.getText()) -> @@ -100,7 +100,8 @@ class CommandPanel extends View @history.push(command) @historyIndex = @history.length if operationsToPreview?.length - @populatePreviewList(operationsToPreview) + @previewList.populate(operationsToPreview) + @previewList.focus() else @detach() catch error @@ -110,11 +111,6 @@ class CommandPanel extends View else throw error - populatePreviewList: (operations) -> - @previewedOperations = operations - @previewList.populate(operations) - @previewList.focus() - navigateBackwardInHistory: -> return if @historyIndex == 0 @historyIndex-- diff --git a/src/extensions/command-panel/preview-list.coffee b/src/extensions/command-panel/preview-list.coffee index c52bd3239..573ca794b 100644 --- a/src/extensions/command-panel/preview-list.coffee +++ b/src/extensions/command-panel/preview-list.coffee @@ -13,6 +13,9 @@ class PreviewList extends View @on 'move-up', => @selectPreviousOperation() @on 'command-panel:execute', => @executeSelectedOperation() + destroy: -> + @destroyOperations() if @operations + hasOperations: -> @operations? populate: (operations) ->