Skip to content

Commit

Permalink
🐛 Fix minimap position not updated if setting change before attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Jan 6, 2015
1 parent 4f00149 commit 4b9b624
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MinimapElement extends HTMLElement

@observeConfig
'minimap.displayMinimapOnLeft': (displayMinimapOnLeft) =>
swapPosition = @attached and displayMinimapOnLeft isnt @displayMinimapOnLeft
swapPosition = @minimap? and displayMinimapOnLeft isnt @displayMinimapOnLeft
@displayMinimapOnLeft = displayMinimapOnLeft

@swapMinimapPosition() if swapPosition
Expand Down
23 changes: 20 additions & 3 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,29 @@ describe 'MinimapElement', ->
expect(minimapElement.requestForcedUpdate).toHaveBeenCalled()

describe 'when minimap.displayMinimapOnLeft setting is true', ->
beforeEach ->
atom.config.set 'minimap.displayMinimapOnLeft', true

it 'moves the attached minimap to the left', ->
atom.config.set 'minimap.displayMinimapOnLeft', true
expect(Array::indexOf.call(editorElement.shadowRoot.children, minimapElement)).toEqual(0)

describe 'when the minimap is not attached yet', ->
beforeEach ->
editor = new TextEditor({})
editor.setLineHeightInPixels(10)
editor.setHeight(50)

minimap = new Minimap({textEditor: editor})

editorElement = atom.views.getView(editor)
minimapElement = atom.views.getView(minimap)

jasmineContent.insertBefore(editorElement, jasmineContent.firstChild)

atom.config.set 'minimap.displayMinimapOnLeft', true
minimapElement.attach()

it 'moves the attached minimap to the left', ->
expect(Array::indexOf.call(editorElement.shadowRoot.children, minimapElement)).toEqual(0)

describe 'when minimap.adjustMinimapWidthToSoftWrap is true', ->
[minimapWidth] = []
beforeEach ->
Expand Down

0 comments on commit 4b9b624

Please sign in to comment.