Skip to content

Commit

Permalink
🐛 💂‍♂️ Try to use the already retrieve pane when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 10, 2014
1 parent 6496aa9 commit 33dd8cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions lib/minimap-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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?
Expand Down
8 changes: 4 additions & 4 deletions lib/mixins/view-management.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 33dd8cf

Please sign in to comment.