mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Handle highlight end rows with 'before' blocks in addition to 'after'
This commit is contained in:
@@ -1698,20 +1698,30 @@ describe('TextEditorComponent', () => {
|
||||
expect(Array.from(marker1Region.parentElement.children).indexOf(marker1Region)).toBe(0)
|
||||
})
|
||||
|
||||
it('correctly positions highlights that end on rows preceding block decorations', async () => {
|
||||
it('correctly positions highlights that end on rows preceding or following block decorations', async () => {
|
||||
const {editor, element, component} = buildComponent()
|
||||
|
||||
const item = document.createElement('div')
|
||||
item.style.height = '30px'
|
||||
const item1 = document.createElement('div')
|
||||
item1.style.height = '30px'
|
||||
item1.style.backgroundColor = 'blue'
|
||||
editor.decorateMarker(editor.markBufferPosition([4, 0]), {
|
||||
type: 'block', position: 'after', item
|
||||
type: 'block', position: 'after', item: item1
|
||||
})
|
||||
const item2 = document.createElement('div')
|
||||
item2.style.height = '30px'
|
||||
item2.style.backgroundColor = 'yellow'
|
||||
editor.decorateMarker(editor.markBufferPosition([4, 0]), {
|
||||
type: 'block', position: 'before', item: item2
|
||||
})
|
||||
editor.decorateMarker(editor.markBufferRange([[3, 0], [4, Infinity]]), {
|
||||
type: 'highlight', class: 'highlight'
|
||||
})
|
||||
editor.setSelectedBufferRange([[3, 0], [4, Infinity]])
|
||||
await component.getNextUpdatePromise()
|
||||
|
||||
const regions = element.querySelectorAll('.selection .region')
|
||||
await component.getNextUpdatePromise()
|
||||
const regions = element.querySelectorAll('.highlight .region')
|
||||
expect(regions[0].offsetTop).toBe(3 * component.getLineHeight())
|
||||
expect(regions[1].offsetTop).toBe(4 * component.getLineHeight())
|
||||
expect(regions[0].offsetHeight).toBe(component.getLineHeight())
|
||||
expect(regions[1].offsetTop).toBe(4 * component.getLineHeight() + 30)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -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) + this.getLineHeight()
|
||||
highlight.endPixelTop = this.pixelPositionAfterBlocksForRow(end.row) + this.getLineHeight()
|
||||
highlight.endPixelLeft = this.pixelLeftForRowAndColumn(end.row, end.column)
|
||||
}
|
||||
this.decorationsToRender.highlights.set(tileRow, highlights)
|
||||
|
||||
Reference in New Issue
Block a user