Skip to content

Commit

Permalink
🐛 Fix minimap size when splitting a pane
Browse files Browse the repository at this point in the history
The original pane’s minimaps was still applying a margin
that was unnecessary.
  • Loading branch information
abe33 committed Feb 1, 2015
1 parent 9872973 commit bbe60dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class MinimapElement extends HTMLElement
update: ->
return unless @attached and @isVisible() and not @minimap.isDestroyed()

if @adjustToSoftWrap
if @adjustToSoftWrap and @marginRight?
@style.marginRight = @marginRight + 'px'
else
@style.marginRight = null
Expand Down Expand Up @@ -320,7 +320,11 @@ class MinimapElement extends HTMLElement
softWrap = atom.config.get('editor.softWrap')
width = lineLength * @minimap.getCharWidth()

@marginRight = width - @width if softWrap and lineLength and width < @width
if softWrap and lineLength and width < @width
@marginRight = width - @width
else
@marginRight = null

canvasWidth = width
else
delete @marginRight
Expand Down
13 changes: 13 additions & 0 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,19 @@ describe 'MinimapElement', ->
nextAnimationFrame()
expect(minimapElement.canvas.width).toEqual(4)

describe 'when the editor is resized', ->
beforeEach ->
atom.config.set 'editor.preferredLineLength', 6
editorElement.style.width = '100px'
editorElement.style.height = '100px'

sleep(150)
runs -> nextAnimationFrame()

it 'makes the minimap smaller than soft wrap', ->
expect(minimapElement.offsetWidth).toBeCloseTo(10, -1)
expect(minimapElement.style.marginRight).toEqual('')

describe 'and when minimap.minimapScrollIndicator setting is true', ->
beforeEach ->
editor.setText(mediumSample)
Expand Down

0 comments on commit bbe60dd

Please sign in to comment.