From 5ac833ed1f9b02fff2cd51c376e2ceacd3aedd1f Mon Sep 17 00:00:00 2001 From: abe33 Date: Sat, 16 Apr 2016 01:28:00 +0200 Subject: [PATCH] Add a gutter decoration type --- lib/mixins/canvas-drawer.js | 13 +++++++++++++ spec/minimap-element-spec.js | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index b8a5f433..1542d320 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -392,6 +392,7 @@ export default class CanvasDrawer extends Mixin { renderData.screenRow = screenRow this.drawDecorations(screenRow, decorations, renderData, { + 'gutter': this.drawGutterDecoration, 'highlight-over': this.drawHighlightDecoration, 'highlight-outline': this.drawHighlightOutlineDecoration, 'foreground-custom': this.drawCustomDecoration @@ -561,6 +562,18 @@ export default class CanvasDrawer extends Mixin { data.context.fillRect(0, data.yRow, data.canvasWidth, data.lineHeight) } + /** + * Draws a gutter decoration. + * + * @param {Decoration} decoration the decoration to render + * @param {Object} data the data need to perform the render + * @access private + */ + drawGutterDecoration (decoration, data) { + data.context.fillStyle = this.getDecorationColor(decoration) + data.context.fillRect(0, data.yRow, 1, data.lineHeight) + } + /** * Draws a highlight decoration. * diff --git a/spec/minimap-element-spec.js b/spec/minimap-element-spec.js index 0e5e502b..f3c49d9e 100644 --- a/spec/minimap-element-spec.js +++ b/spec/minimap-element-spec.js @@ -318,6 +318,24 @@ describe('MinimapElement', () => { }) }) + it('renders the visible gutter decorations', () => { + spyOn(minimapElement, 'drawGutterDecoration').andCallThrough() + + minimap.decorateMarker(editor.markBufferRange([[1, 0], [1, 10]]), {type: 'gutter', color: '#0000FF'}) + minimap.decorateMarker(editor.markBufferRange([[10, 0], [10, 10]]), {type: 'gutter', color: '#0000FF'}) + minimap.decorateMarker(editor.markBufferRange([[100, 0], [100, 10]]), {type: 'gutter', color: '#0000FF'}) + + editorElement.setScrollTop(0) + + waitsFor(() => { return nextAnimationFrame !== noAnimationFrame }) + runs(() => { + nextAnimationFrame() + + expect(minimapElement.drawGutterDecoration).toHaveBeenCalled() + expect(minimapElement.drawGutterDecoration.calls.length).toEqual(2) + }) + }) + it('renders the visible highlight decorations', () => { spyOn(minimapElement, 'drawHighlightDecoration').andCallThrough()