diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index e65e09e5d..1c37c549d 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -1697,6 +1697,22 @@ describe('TextEditorComponent', () => { await component.getNextUpdatePromise() expect(Array.from(marker1Region.parentElement.children).indexOf(marker1Region)).toBe(0) }) + + it('correctly positions highlights that end on rows preceding block decorations', async () => { + const {editor, element, component} = buildComponent() + + const item = document.createElement('div') + item.style.height = '30px' + editor.decorateMarker(editor.markBufferPosition([4, 0]), { + type: 'block', position: 'after', item + }) + editor.setSelectedBufferRange([[3, 0], [4, Infinity]]) + await component.getNextUpdatePromise() + + const regions = element.querySelectorAll('.selection .region') + expect(regions[0].offsetTop).toBe(3 * component.getLineHeight()) + expect(regions[1].offsetTop).toBe(4 * component.getLineHeight()) + }) }) describe('overlay decorations', () => { diff --git a/src/text-editor-component.js b/src/text-editor-component.js index e89bcd509..3c9e5b569 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1316,7 +1316,7 @@ class TextEditorComponent { const {start, end} = highlight.screenRange highlight.startPixelTop = this.pixelPositionAfterBlocksForRow(start.row) highlight.startPixelLeft = this.pixelLeftForRowAndColumn(start.row, start.column) - highlight.endPixelTop = this.pixelPositionBeforeBlocksForRow(end.row + 1) + highlight.endPixelTop = this.pixelPositionBeforeBlocksForRow(end.row) + this.getLineHeight() highlight.endPixelLeft = this.pixelLeftForRowAndColumn(end.row, end.column) } this.decorationsToRender.highlights.set(tileRow, highlights)