diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index 99d4c277..2361e62b 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -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 diff --git a/spec/minimap-element-spec.coffee b/spec/minimap-element-spec.coffee index 48255f72..6d03e9b3 100644 --- a/spec/minimap-element-spec.coffee +++ b/spec/minimap-element-spec.coffee @@ -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 ->