Skip to content

Commit d704e05

Browse files
committed
Merge pull request #49 from fundon/dev
Hotfix, broken minimap activation on non editor view
2 parents e5777aa + cbcc3f1 commit d704e05

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

History.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.6.0 / 2014-04-04
2+
==================
3+
4+
* fix broken minimap activation on non editor view, #46
5+
* move resizeend to main file
6+
17
0.5.0 / 2014-04-03
28
==================
39

lib/minimap-view.coffee

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ Debug = require './mixins/debug'
55

66
CONFIGS = require './config'
77

8-
require '../vendor/resizeend'
9-
108
module.exports =
119
class MinimapView extends View
1210
Debug.includeInto(this)
@@ -81,10 +79,10 @@ class MinimapView extends View
8179

8280
storeActiveEditor: ->
8381
@editorView = @getEditorView()
82+
@editor = @editorView.getEditor()
8483

8584
@unsubscribeFromEditor()
8685

87-
@editor = @editorView.getEditor()
8886
@scrollView = @editorView.scrollView
8987
@scrollViewLines = @scrollView.find('.lines')
9088

@@ -98,12 +96,19 @@ class MinimapView extends View
9896
@subscribe @editor, 'scroll-top-changed.minimap', @updateScroll
9997
#@subscribe @editor, 'scroll-left-changed.minimap', @updateScroll
10098

99+
# See /Applications/Atom.app/Contents/Resources/app/src/pane-view.js#349
100+
# pane-view's private api
101+
# `paneView.activeView` and `paneView.activeItem`
101102
getEditorView: -> @paneView.viewForItem(@activeItem)
102103

103104
getEditorViewClientRect: -> @scrollView[0].getBoundingClientRect()
104105

105106
getScrollViewClientRect: -> @scrollViewLines[0].getBoundingClientRect()
106107

108+
# See https://atom.io/docs/api/v0.83.0/api/classes/Pane.html#getActiveEditor-instance
109+
# Returns an Editor if the pane item is an Editor, or null otherwise.
110+
getEditor: -> @paneView.model.getActiveEditor()
111+
107112
setMinimapEditorView: ->
108113
# update minimap-editor
109114
setImmediate => @miniEditorView.setEditorView(@editorView)
@@ -116,6 +121,7 @@ class MinimapView extends View
116121
updateMinimapEditorView: => @miniEditorView.update()
117122

118123
updateMinimapView: =>
124+
return unless @editorView
119125
# offset minimap
120126
@offset top: @editorView.offset().top
121127

@@ -154,14 +160,15 @@ class MinimapView extends View
154160

155161
onActiveItemChanged: (item) =>
156162
# Fix called twice when opening minimap!
157-
return if @activeItem == item
163+
return if item is @activeItem
158164
@activeItem = item
159165

160166
if @activeTabSupportMinimap()
161167
@log 'minimap is supported by the current tab'
162168
@activatePaneViewMinimap() unless @minimapIsAttached()
163169
@storeActiveEditor()
164170
@setMinimapEditorView()
171+
@updateMinimapView()
165172
else
166173
# Ignore any tab that is not an editor
167174
@deactivatePaneViewMinimap()
@@ -195,12 +202,11 @@ class MinimapView extends View
195202
@isClicked = false
196203
, 377
197204

198-
onScrollViewResized: =>
199-
@updateMinimapView()
205+
onScrollViewResized: => @updateMinimapView()
200206

201207
onDragStart: (e) =>
202208
# only supports for left-click
203-
return unless e.which is 1
209+
return if e.which isnt 1
204210
@isPressed = true
205211
@on 'mousemove.visible-area', @onMove
206212
@on 'mouseup.visible-area', @onDragEnd
@@ -214,10 +220,7 @@ class MinimapView extends View
214220

215221
# OTHER PRIVATE METHODS
216222

217-
activeTabSupportMinimap: ->
218-
editorView = @getEditorView()
219-
220-
editorView? and editorView.hasClass('editor')
223+
activeTabSupportMinimap: -> @getEditor()
221224

222225
scale: (x=1,y=1) -> "scale(#{x}, #{y}) "
223226
translateY: (y=0) -> "translate3d(0, #{y}px, 0)"

lib/minimap.coffee

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{Emitter} = require 'emissary'
22
MinimapView = require './minimap-view'
33

4+
require '../vendor/resizeend'
5+
46
class Minimap
57
Emitter.includeInto(this)
68

@@ -27,13 +29,13 @@ class Minimap
2729
toggle: (debugMode=false) ->
2830
@allowDebug = debugMode
2931
if @active
32+
@active = false
3033
@deactivate()
3134
else
3235
@open()
36+
@active = true
3337
@emit('activated')
3438

35-
@active = not @active
36-
3739
toggleDebug: ->
3840
@toggle(true)
3941

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "minimap",
33
"main": "./lib/minimap",
4-
"version": "0.5.0",
4+
"version": "0.6.0",
55
"private": true,
66
"description": "A preview of the full source code.",
77
"author": "Fangdun Cai <[email protected]>",

0 commit comments

Comments
 (0)