Skip to content

Commit

Permalink
Add a gutter decoration type
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Apr 15, 2016
1 parent a1ad0e4 commit 5ac833e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
*
Expand Down
18 changes: 18 additions & 0 deletions spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 5ac833e

Please sign in to comment.