Skip to content

Commit

Permalink
Implement partial redraw on editor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 16, 2014
1 parent 0c6849d commit 0c50eb5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class MinimapElement extends HTMLElement
setModel: (@minimap) ->
@subscriptions.add @minimap.onDidChangeScrollTop => @requestUpdate()
@subscriptions.add @minimap.onDidChangeScrollLeft => @requestUpdate()
@subscriptions.add @minimap.onDidChange (change) =>
@pendingChanges.push(change)
@requestUpdate()

@minimap

Expand Down
18 changes: 18 additions & 0 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,24 @@ describe 'MinimapElement', ->
expect(canvas.offsetWidth).toEqual(minimapElement.offsetWidth)
expect(canvas.offsetHeight).toEqual(minimapElement.offsetHeight + minimap.getLineHeight())

describe 'when the editor visible content is changed', ->

beforeEach ->
editor.setScrollLeft(0)
editor.setScrollTop(1400)
editor.setSelectedBufferRange [[101, 0], [102, 20]]
nextAnimationFrame()

spyOn(minimapElement, 'drawLines').andCallThrough()
editor.insertText 'foo'

it 'rerenders the part that have changed', ->
nextAnimationFrame()

expect(minimapElement.drawLines).toHaveBeenCalled()
expect(minimapElement.drawLines.calls[1].args[1]).toEqual(100)
expect(minimapElement.drawLines.calls[1].args[2]).toEqual(101)

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

0 comments on commit 0c50eb5

Please sign in to comment.