From 0c50eb559070b0a2047b0ab32820ad6efd6b6b7a Mon Sep 17 00:00:00 2001 From: abe33 Date: Tue, 16 Dec 2014 12:02:42 +0100 Subject: [PATCH] Implement partial redraw on editor changes --- lib/minimap-element.coffee | 3 +++ spec/minimap-element-spec.coffee | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) 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