diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index 5b237c1c..e4e6da93 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -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 diff --git a/spec/minimap-element-spec.coffee b/spec/minimap-element-spec.coffee index acf5794f..fbbf4672 100644 --- a/spec/minimap-element-spec.coffee +++ b/spec/minimap-element-spec.coffee @@ -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