Skip to content

Commit

Permalink
🐛 Fix minimap redraw when scrolling down
Browse files Browse the repository at this point in the history
By adding an extra line to the canvas we are sure to render more than
the height and have enough content to paste on the offscreen buffer
  • Loading branch information
abe33 committed Dec 15, 2014
1 parent fe2ba61 commit d3edad1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ class MinimapElement extends HTMLElement
@shadowRoot.appendChild(@visibleArea)

measureHeightAndWidth: ->
editorElement = @getTextEditorElement()
width = @clientWidth
height = @clientHeight
@width = @clientWidth
@height = @clientHeight

if width isnt @canvas.width or height isnt @canvas.height
@canvas.width = width * devicePixelRatio
@canvas.height = height * devicePixelRatio
if @width isnt @canvas.width or @height isnt @canvas.height
@canvas.width = @width * devicePixelRatio
@canvas.height = (@height + @minimap.getLineHeight()) * devicePixelRatio

getTextEditor: -> @minimap.getTextEditor()

Expand Down
2 changes: 1 addition & 1 deletion spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe 'MinimapElement', ->
expect(minimapElement.offsetWidth).toBeCloseTo(editorElement.clientWidth / 10, -1)

it 'resizes the canvas to fit the minimap', ->
expect(canvas.offsetHeight).toEqual(minimapElement.offsetHeight)
expect(canvas.offsetHeight).toEqual(minimapElement.offsetHeight + minimap.getLineHeight())
expect(canvas.offsetWidth).toEqual(minimapElement.offsetWidth)

it 'requests an update', ->
Expand Down

0 comments on commit d3edad1

Please sign in to comment.