From 33dd8cf6bc3f9bf51d3a4cdc4b1c2dcd842a9001 Mon Sep 17 00:00:00 2001 From: abe33 Date: Wed, 10 Dec 2014 10:35:00 +0100 Subject: [PATCH] :bug: :guardsman: Try to use the already retrieve pane when possible --- lib/minimap-view.coffee | 10 +++++++--- lib/mixins/view-management.coffee | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/minimap-view.coffee b/lib/minimap-view.coffee index 9a9a3249..c6e471bb 100644 --- a/lib/minimap-view.coffee +++ b/lib/minimap-view.coffee @@ -75,7 +75,7 @@ class MinimapView extends View # Creates a new {MinimapView}. # # editorView - The `TextEditorView` for which displaying a minimap. - constructor: (editorView) -> + constructor: (editorView, @paneView) -> @emitter = new Emitter @setEditorView(editorView) @@ -213,8 +213,12 @@ class MinimapView extends View setEditorView: (@editorView) -> @editor = @editorView.getModel() - @pane = atom.workspace.paneForItem(@editor) - @paneView = atom.views.getView(@pane) + if @paneView? + @pane = @paneView.getModel() + else + @pane = atom.workspace.paneForItem(@editor) + @paneView = atom.views.getView(@pane) + @renderView?.setEditorView(@editorView) if @obsPane? diff --git a/lib/mixins/view-management.coffee b/lib/mixins/view-management.coffee index 5c2cda90..0eb6910d 100644 --- a/lib/mixins/view-management.coffee +++ b/lib/mixins/view-management.coffee @@ -87,22 +87,22 @@ class ViewManagement extends Mixin @updateAllViews() onEditorAdded: (editor, pane) -> - editorView = atom.views.getView(editor) - MinimapView ||= require '../minimap-view' editorId = editor.id + editorView = atom.views.getView(editor) paneView = atom.views.getView(pane) - return unless paneView? + return unless editorView? and paneView? if (view = @minimapViews[editorId])? + view.paneView = paneView view.setEditorView editorView view.detachFromPaneView() view.attachToPaneView() return - view = new MinimapView(editorView) + view = new MinimapView(editorView, paneView) @minimapViews[editorId] = view