mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Reimplement block decorations without the shadow DOM
This commit is contained in:
@@ -405,49 +405,49 @@ describe('TextEditorComponent', function () {
|
||||
}
|
||||
})
|
||||
|
||||
it('applies .syntax--leading-whitespace for lines with leading spaces and/or tabs', function () {
|
||||
it('applies .leading-whitespace for lines with leading spaces and/or tabs', function () {
|
||||
editor.setText(' a')
|
||||
|
||||
runAnimationFrames()
|
||||
|
||||
let leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(leafNodes[0].classList.contains('syntax--leading-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('syntax--trailing-whitespace')).toBe(false)
|
||||
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe(false)
|
||||
|
||||
editor.setText('\ta')
|
||||
runAnimationFrames()
|
||||
|
||||
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(leafNodes[0].classList.contains('syntax--leading-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('syntax--trailing-whitespace')).toBe(false)
|
||||
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe(false)
|
||||
})
|
||||
|
||||
it('applies .syntax--trailing-whitespace for lines with trailing spaces and/or tabs', function () {
|
||||
it('applies .trailing-whitespace for lines with trailing spaces and/or tabs', function () {
|
||||
editor.setText(' ')
|
||||
runAnimationFrames()
|
||||
|
||||
let leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(leafNodes[0].classList.contains('syntax--trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('syntax--leading-whitespace')).toBe(false)
|
||||
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe(false)
|
||||
|
||||
editor.setText('\t')
|
||||
runAnimationFrames()
|
||||
|
||||
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(leafNodes[0].classList.contains('syntax--trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('syntax--leading-whitespace')).toBe(false)
|
||||
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe(false)
|
||||
editor.setText('a ')
|
||||
runAnimationFrames()
|
||||
|
||||
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(leafNodes[0].classList.contains('syntax--trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('syntax--leading-whitespace')).toBe(false)
|
||||
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe(false)
|
||||
editor.setText('a\t')
|
||||
runAnimationFrames()
|
||||
|
||||
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(leafNodes[0].classList.contains('syntax--trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('syntax--leading-whitespace')).toBe(false)
|
||||
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps rebuilding lines when continuous reflow is on', function () {
|
||||
@@ -501,14 +501,14 @@ describe('TextEditorComponent', function () {
|
||||
expect(component.lineNodeForScreenRow(0).textContent).toBe('' + invisibles.space + 'a line with tabs' + invisibles.tab + 'and spaces' + invisibles.space + invisibles.eol)
|
||||
|
||||
let leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(leafNodes[0].classList.contains('syntax--invisible-character')).toBe(true)
|
||||
expect(leafNodes[leafNodes.length - 1].classList.contains('syntax--invisible-character')).toBe(true)
|
||||
expect(leafNodes[0].classList.contains('invisible-character')).toBe(true)
|
||||
expect(leafNodes[leafNodes.length - 1].classList.contains('invisible-character')).toBe(true)
|
||||
})
|
||||
|
||||
it('displays newlines as their own token outside of the other tokens\' scopeDescriptor', function () {
|
||||
editor.setText('let\n')
|
||||
runAnimationFrames()
|
||||
expect(component.lineNodeForScreenRow(0).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="syntax--storage syntax--type syntax--var syntax--js">let</span><span class="syntax--invisible-character syntax--eol">' + invisibles.eol + '</span></span>')
|
||||
expect(component.lineNodeForScreenRow(0).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="syntax--storage syntax--type syntax--var syntax--js">let</span><span class="invisible-character eol">' + invisibles.eol + '</span></span>')
|
||||
})
|
||||
|
||||
it('displays trailing carriage returns using a visible, non-empty value', function () {
|
||||
@@ -543,20 +543,20 @@ describe('TextEditorComponent', function () {
|
||||
normalizeLineEndings: false
|
||||
})
|
||||
runAnimationFrames()
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="syntax--invisible-character syntax--eol syntax--indent-guide">CE</span></span>')
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="invisible-character eol indent-guide">CE</span></span>')
|
||||
|
||||
editor.setTabLength(3)
|
||||
runAnimationFrames()
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="syntax--invisible-character syntax--eol syntax--indent-guide">CE</span></span>')
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="invisible-character eol indent-guide">CE</span></span>')
|
||||
|
||||
editor.setTabLength(1)
|
||||
runAnimationFrames()
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="syntax--invisible-character syntax--eol syntax--indent-guide">CE</span></span>')
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="invisible-character eol indent-guide">CE</span></span>')
|
||||
|
||||
editor.setTextInBufferRange([[9, 0], [9, Infinity]], ' ')
|
||||
editor.setTextInBufferRange([[11, 0], [11, Infinity]], ' ')
|
||||
runAnimationFrames()
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="syntax--invisible-character syntax--eol syntax--indent-guide">CE</span></span>')
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe('<span class="syntax--source syntax--js"><span class="invisible-character eol indent-guide">CE</span></span>')
|
||||
})
|
||||
|
||||
describe('when soft wrapping is enabled', function () {
|
||||
@@ -583,30 +583,30 @@ describe('TextEditorComponent', function () {
|
||||
runAnimationFrames()
|
||||
})
|
||||
|
||||
it('adds an "syntax--indent-guide" class to spans comprising the leading whitespace', function () {
|
||||
it('adds an "indent-guide" class to spans comprising the leading whitespace', function () {
|
||||
let line1LeafNodes = getLeafNodes(component.lineNodeForScreenRow(1))
|
||||
expect(line1LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line1LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line1LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(false)
|
||||
expect(line1LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line1LeafNodes[1].classList.contains('indent-guide')).toBe(false)
|
||||
|
||||
let line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2))
|
||||
expect(line2LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[1].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[2].classList.contains('syntax--indent-guide')).toBe(false)
|
||||
expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe(false)
|
||||
})
|
||||
|
||||
it('renders leading whitespace spans with the "syntax--indent-guide" class for empty lines', function () {
|
||||
it('renders leading whitespace spans with the "indent-guide" class for empty lines', function () {
|
||||
editor.getBuffer().insert([1, Infinity], '\n')
|
||||
runAnimationFrames()
|
||||
|
||||
let line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2))
|
||||
expect(line2LeafNodes.length).toBe(2)
|
||||
expect(line2LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[1].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe(true)
|
||||
})
|
||||
|
||||
it('renders indent guides correctly on lines containing only whitespace', function () {
|
||||
@@ -616,11 +616,11 @@ describe('TextEditorComponent', function () {
|
||||
let line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2))
|
||||
expect(line2LeafNodes.length).toBe(3)
|
||||
expect(line2LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[1].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[2].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[2].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe(true)
|
||||
})
|
||||
|
||||
it('renders indent guides correctly on lines containing only whitespace when invisibles are enabled', function () {
|
||||
@@ -638,11 +638,11 @@ describe('TextEditorComponent', function () {
|
||||
let line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2))
|
||||
expect(line2LeafNodes.length).toBe(4)
|
||||
expect(line2LeafNodes[0].textContent).toBe('--')
|
||||
expect(line2LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[1].textContent).toBe('--')
|
||||
expect(line2LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[2].textContent).toBe('--')
|
||||
expect(line2LeafNodes[2].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line2LeafNodes[3].textContent).toBe('x')
|
||||
})
|
||||
|
||||
@@ -653,9 +653,9 @@ describe('TextEditorComponent', function () {
|
||||
|
||||
let line0LeafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
|
||||
expect(line0LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line0LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line0LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line0LeafNodes[1].textContent).toBe(' ')
|
||||
expect(line0LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(false)
|
||||
expect(line0LeafNodes[1].classList.contains('indent-guide')).toBe(false)
|
||||
})
|
||||
|
||||
it('updates the indent guides on empty lines preceding an indentation change', function () {
|
||||
@@ -667,9 +667,9 @@ describe('TextEditorComponent', function () {
|
||||
|
||||
let line12LeafNodes = getLeafNodes(component.lineNodeForScreenRow(12))
|
||||
expect(line12LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line12LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line12LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line12LeafNodes[1].textContent).toBe(' ')
|
||||
expect(line12LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line12LeafNodes[1].classList.contains('indent-guide')).toBe(true)
|
||||
})
|
||||
|
||||
it('updates the indent guides on empty lines following an indentation change', function () {
|
||||
@@ -682,9 +682,9 @@ describe('TextEditorComponent', function () {
|
||||
|
||||
let line13LeafNodes = getLeafNodes(component.lineNodeForScreenRow(13))
|
||||
expect(line13LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line13LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line13LeafNodes[0].classList.contains('indent-guide')).toBe(true)
|
||||
expect(line13LeafNodes[1].textContent).toBe(' ')
|
||||
expect(line13LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(true)
|
||||
expect(line13LeafNodes[1].classList.contains('indent-guide')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -701,11 +701,11 @@ describe('TextEditorComponent', function () {
|
||||
let line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2))
|
||||
expect(line2LeafNodes.length).toBe(3)
|
||||
expect(line2LeafNodes[0].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[0].classList.contains('syntax--indent-guide')).toBe(false)
|
||||
expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe(false)
|
||||
expect(line2LeafNodes[1].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[1].classList.contains('syntax--indent-guide')).toBe(false)
|
||||
expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe(false)
|
||||
expect(line2LeafNodes[2].textContent).toBe(' ')
|
||||
expect(line2LeafNodes[2].classList.contains('syntax--indent-guide')).toBe(false)
|
||||
expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -720,19 +720,19 @@ describe('TextEditorComponent', function () {
|
||||
describe('when there is a fold', function () {
|
||||
it('renders a fold marker on the folded line', function () {
|
||||
let foldedLineNode = component.lineNodeForScreenRow(4)
|
||||
expect(foldedLineNode.querySelector('.syntax--fold-marker')).toBeFalsy()
|
||||
expect(foldedLineNode.querySelector('.fold-marker')).toBeFalsy()
|
||||
editor.foldBufferRow(4)
|
||||
|
||||
runAnimationFrames()
|
||||
|
||||
foldedLineNode = component.lineNodeForScreenRow(4)
|
||||
expect(foldedLineNode.querySelector('.syntax--fold-marker')).toBeTruthy()
|
||||
expect(foldedLineNode.querySelector('.fold-marker')).toBeTruthy()
|
||||
editor.unfoldBufferRow(4)
|
||||
|
||||
runAnimationFrames()
|
||||
|
||||
foldedLineNode = component.lineNodeForScreenRow(4)
|
||||
expect(foldedLineNode.querySelector('.syntax--fold-marker')).toBeFalsy()
|
||||
expect(foldedLineNode.querySelector('.fold-marker')).toBeFalsy()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1284,7 +1284,7 @@ describe('TextEditorComponent', function () {
|
||||
runAnimationFrames()
|
||||
|
||||
let cursorRect = componentNode.querySelector('.cursor').getBoundingClientRect()
|
||||
let foldMarkerRect = componentNode.querySelector('.syntax--fold-marker').getBoundingClientRect()
|
||||
let foldMarkerRect = componentNode.querySelector('.fold-marker').getBoundingClientRect()
|
||||
expect(cursorRect.left).toBeCloseTo(foldMarkerRect.right, 0)
|
||||
})
|
||||
|
||||
@@ -1771,32 +1771,32 @@ describe('TextEditorComponent', function () {
|
||||
let [item3, blockDecoration3] = createBlockDecorationBeforeScreenRow(4, {className: "decoration-3"})
|
||||
let [item4, blockDecoration4] = createBlockDecorationBeforeScreenRow(7, {className: "decoration-4"})
|
||||
let [item5, blockDecoration5] = createBlockDecorationAfterScreenRow(7, {className: "decoration-5"})
|
||||
let [item6, blockDecoration6] = createBlockDecorationAfterScreenRow(12, {className: "decoration-6"})
|
||||
|
||||
atom.styles.addStyleSheet(
|
||||
`atom-text-editor .decoration-1 { width: 30px; height: 80px; }
|
||||
atom-text-editor .decoration-2 { width: 30px; height: 40px; }
|
||||
atom-text-editor .decoration-3 { width: 30px; height: 100px; }
|
||||
atom-text-editor .decoration-4 { width: 30px; height: 120px; }
|
||||
atom-text-editor .decoration-5 { width: 30px; height: 42px; }`,
|
||||
atom-text-editor .decoration-5 { width: 30px; height: 42px; }
|
||||
atom-text-editor .decoration-6 { width: 30px; height: 22px; }`,
|
||||
{context: 'atom-text-editor'}
|
||||
)
|
||||
runAnimationFrames()
|
||||
|
||||
expect(component.getDomNode().querySelectorAll(".line").length).toBe(7)
|
||||
|
||||
expect(verticalScrollbarNode.scrollHeight).toBe(editor.getScreenLineCount() * editor.getLineHeightInPixels() + 80 + 40 + 100 + 120 + 42 + 22)
|
||||
expect(component.tileNodesForLines()[0].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 80 + 40 + "px")
|
||||
expect(component.tileNodesForLines()[0].style.webkitTransform).toBe("translate3d(0px, 0px, 0px)")
|
||||
expect(component.tileNodesForLines()[1].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 100 + "px")
|
||||
expect(component.tileNodesForLines()[1].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight}px, 0px)`)
|
||||
expect(component.tileNodesForLines()[2].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 120 + 42 + "px")
|
||||
expect(component.tileNodesForLines()[2].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight + component.tileNodesForLines()[1].offsetHeight}px, 0px)`)
|
||||
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-1")).toBe(item1)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-2")).toBe(item2)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-3")).toBe(item3)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-4")).toBeNull()
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-5")).toBeNull()
|
||||
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-6")).toBeNull()
|
||||
expect(item1.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 0)
|
||||
expect(item2.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 2 + 80)
|
||||
expect(item3.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 4 + 80 + 40)
|
||||
@@ -1804,24 +1804,21 @@ describe('TextEditorComponent', function () {
|
||||
editor.setCursorScreenPosition([0, 0])
|
||||
editor.insertNewline()
|
||||
blockDecoration1.destroy()
|
||||
|
||||
runAnimationFrames()
|
||||
|
||||
expect(component.getDomNode().querySelectorAll(".line").length).toBe(7)
|
||||
|
||||
expect(verticalScrollbarNode.scrollHeight).toBe(editor.getScreenLineCount() * editor.getLineHeightInPixels() + 40 + 100 + 120 + 42 + 22)
|
||||
expect(component.tileNodesForLines()[0].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + "px")
|
||||
expect(component.tileNodesForLines()[0].style.webkitTransform).toBe("translate3d(0px, 0px, 0px)")
|
||||
expect(component.tileNodesForLines()[1].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 100 + 40 + "px")
|
||||
expect(component.tileNodesForLines()[1].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight}px, 0px)`)
|
||||
expect(component.tileNodesForLines()[2].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 120 + 42 + "px")
|
||||
expect(component.tileNodesForLines()[2].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight + component.tileNodesForLines()[1].offsetHeight}px, 0px)`)
|
||||
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-1")).toBeNull()
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-2")).toBe(item2)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-3")).toBe(item3)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-4")).toBeNull()
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-5")).toBeNull()
|
||||
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-6")).toBeNull()
|
||||
expect(item2.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 3)
|
||||
expect(item3.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 5 + 40)
|
||||
|
||||
@@ -1832,52 +1829,71 @@ describe('TextEditorComponent', function () {
|
||||
|
||||
runAnimationFrames() // causes the DOM to update and to retrieve new styles
|
||||
runAnimationFrames() // applies the changes
|
||||
|
||||
expect(component.getDomNode().querySelectorAll(".line").length).toBe(7)
|
||||
|
||||
expect(verticalScrollbarNode.scrollHeight).toBe(editor.getScreenLineCount() * editor.getLineHeightInPixels() + 60 + 100 + 120 + 42 + 22)
|
||||
expect(component.tileNodesForLines()[0].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + "px")
|
||||
expect(component.tileNodesForLines()[0].style.webkitTransform).toBe("translate3d(0px, 0px, 0px)")
|
||||
expect(component.tileNodesForLines()[1].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 100 + 60 + "px")
|
||||
expect(component.tileNodesForLines()[1].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight}px, 0px)`)
|
||||
expect(component.tileNodesForLines()[2].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 120 + 42 + "px")
|
||||
expect(component.tileNodesForLines()[2].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight + component.tileNodesForLines()[1].offsetHeight}px, 0px)`)
|
||||
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-1")).toBeNull()
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-2")).toBe(item2)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-3")).toBe(item3)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-4")).toBeNull()
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-5")).toBeNull()
|
||||
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-6")).toBeNull()
|
||||
expect(item2.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 3)
|
||||
expect(item3.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 5 + 60)
|
||||
|
||||
item2.style.height = "20px"
|
||||
wrapperNode.invalidateBlockDecorationDimensions(blockDecoration2)
|
||||
runAnimationFrames()
|
||||
runAnimationFrames()
|
||||
|
||||
runAnimationFrames() // causes the DOM to update and to retrieve new styles
|
||||
runAnimationFrames() // applies the changes
|
||||
expect(component.getDomNode().querySelectorAll(".line").length).toBe(9)
|
||||
|
||||
expect(verticalScrollbarNode.scrollHeight).toBe(editor.getScreenLineCount() * editor.getLineHeightInPixels() + 20 + 100 + 120 + 42 + 22)
|
||||
expect(component.tileNodesForLines()[0].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + "px")
|
||||
expect(component.tileNodesForLines()[0].style.webkitTransform).toBe("translate3d(0px, 0px, 0px)")
|
||||
expect(component.tileNodesForLines()[1].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 100 + 20 + "px")
|
||||
expect(component.tileNodesForLines()[1].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight}px, 0px)`)
|
||||
expect(component.tileNodesForLines()[2].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 120 + 42 + "px")
|
||||
expect(component.tileNodesForLines()[2].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight + component.tileNodesForLines()[1].offsetHeight}px, 0px)`)
|
||||
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-1")).toBeNull()
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-2")).toBe(item2)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-3")).toBe(item3)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-4")).toBe(item4)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-5")).toBe(item5)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-6")).toBeNull()
|
||||
expect(item2.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 3)
|
||||
expect(item3.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 5 + 20)
|
||||
expect(item4.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 8 + 20 + 100)
|
||||
expect(item5.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 8 + 20 + 100 + 120 + lineHeightInPixels)
|
||||
|
||||
item6.style.height = "33px"
|
||||
wrapperNode.invalidateBlockDecorationDimensions(blockDecoration6)
|
||||
runAnimationFrames() // causes the DOM to update and to retrieve new styles
|
||||
runAnimationFrames() // applies the changes
|
||||
expect(component.getDomNode().querySelectorAll(".line").length).toBe(9)
|
||||
expect(verticalScrollbarNode.scrollHeight).toBe(editor.getScreenLineCount() * editor.getLineHeightInPixels() + 20 + 100 + 120 + 42 + 33)
|
||||
expect(component.tileNodesForLines()[0].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + "px")
|
||||
expect(component.tileNodesForLines()[0].style.webkitTransform).toBe("translate3d(0px, 0px, 0px)")
|
||||
expect(component.tileNodesForLines()[1].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 100 + 20 + "px")
|
||||
expect(component.tileNodesForLines()[1].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight}px, 0px)`)
|
||||
expect(component.tileNodesForLines()[2].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + 120 + 42 + "px")
|
||||
expect(component.tileNodesForLines()[2].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight + component.tileNodesForLines()[1].offsetHeight}px, 0px)`)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-1")).toBeNull()
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-2")).toBe(item2)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-3")).toBe(item3)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-4")).toBe(item4)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-5")).toBe(item5)
|
||||
expect(component.getTopmostDOMNode().querySelector(".decoration-6")).toBeNull()
|
||||
expect(item2.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 3)
|
||||
expect(item3.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 5 + 20)
|
||||
expect(item4.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 8 + 20 + 100)
|
||||
expect(item5.getBoundingClientRect().top).toBe(editor.getLineHeightInPixels() * 8 + 20 + 100 + 120 + lineHeightInPixels)
|
||||
})
|
||||
|
||||
it("correctly sets screen rows on <content> elements, both initially and when decorations move", function () {
|
||||
it("correctly sets screen rows on block decoration and ruler nodes, both initially and when decorations move", function () {
|
||||
let [item, blockDecoration] = createBlockDecorationBeforeScreenRow(0, {className: "decoration-1"})
|
||||
atom.styles.addStyleSheet(
|
||||
'atom-text-editor .decoration-1 { width: 30px; height: 80px; }',
|
||||
@@ -1885,42 +1901,37 @@ describe('TextEditorComponent', function () {
|
||||
)
|
||||
|
||||
runAnimationFrames()
|
||||
|
||||
let tileNode, contentElements
|
||||
|
||||
tileNode = component.tileNodesForLines()[0]
|
||||
contentElements = tileNode.querySelectorAll("content")
|
||||
|
||||
expect(contentElements.length).toBe(1)
|
||||
expect(contentElements[0].dataset.screenRow).toBe("0")
|
||||
expect(component.lineNodeForScreenRow(0).dataset.screenRow).toBe("0")
|
||||
expect(component.lineNodeForScreenRow(1).dataset.screenRow).toBe("1")
|
||||
expect(component.lineNodeForScreenRow(2).dataset.screenRow).toBe("2")
|
||||
const line0 = component.lineNodeForScreenRow(0)
|
||||
expect(item.previousSibling.dataset.screenRow).toBe("0")
|
||||
expect(item.dataset.screenRow).toBe("0")
|
||||
expect(item.nextSibling.dataset.screenRow).toBe("0")
|
||||
expect(line0.previousSibling).toBe(item.nextSibling)
|
||||
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
editor.insertNewline()
|
||||
runAnimationFrames()
|
||||
const line1 = component.lineNodeForScreenRow(1)
|
||||
expect(item.previousSibling.dataset.screenRow).toBe("1")
|
||||
expect(item.dataset.screenRow).toBe("1")
|
||||
expect(item.nextSibling.dataset.screenRow).toBe("1")
|
||||
expect(line1.previousSibling).toBe(item.nextSibling)
|
||||
|
||||
tileNode = component.tileNodesForLines()[0]
|
||||
contentElements = tileNode.querySelectorAll("content")
|
||||
|
||||
expect(contentElements.length).toBe(1)
|
||||
expect(contentElements[0].dataset.screenRow).toBe("1")
|
||||
expect(component.lineNodeForScreenRow(0).dataset.screenRow).toBe("0")
|
||||
expect(component.lineNodeForScreenRow(1).dataset.screenRow).toBe("1")
|
||||
expect(component.lineNodeForScreenRow(2).dataset.screenRow).toBe("2")
|
||||
|
||||
blockDecoration.getMarker().setHeadBufferPosition([2, 0])
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
editor.insertNewline()
|
||||
runAnimationFrames()
|
||||
const line2 = component.lineNodeForScreenRow(2)
|
||||
expect(item.previousSibling.dataset.screenRow).toBe("2")
|
||||
expect(item.dataset.screenRow).toBe("2")
|
||||
expect(item.nextSibling.dataset.screenRow).toBe("2")
|
||||
expect(line2.previousSibling).toBe(item.nextSibling)
|
||||
|
||||
tileNode = component.tileNodesForLines()[0]
|
||||
contentElements = tileNode.querySelectorAll("content")
|
||||
|
||||
expect(contentElements.length).toBe(1)
|
||||
expect(contentElements[0].dataset.screenRow).toBe("2")
|
||||
expect(component.lineNodeForScreenRow(0).dataset.screenRow).toBe("0")
|
||||
expect(component.lineNodeForScreenRow(1).dataset.screenRow).toBe("1")
|
||||
expect(component.lineNodeForScreenRow(2).dataset.screenRow).toBe("2")
|
||||
blockDecoration.getMarker().setHeadBufferPosition([4, 0])
|
||||
runAnimationFrames()
|
||||
const line4 = component.lineNodeForScreenRow(4)
|
||||
expect(item.previousSibling.dataset.screenRow).toBe("4")
|
||||
expect(item.dataset.screenRow).toBe("4")
|
||||
expect(item.nextSibling.dataset.screenRow).toBe("4")
|
||||
expect(line4.previousSibling).toBe(item.nextSibling)
|
||||
})
|
||||
|
||||
it('measures block decorations taking into account both top and bottom margins of the element and its children', function () {
|
||||
@@ -1945,6 +1956,18 @@ describe('TextEditorComponent', function () {
|
||||
expect(component.tileNodesForLines()[2].style.height).toBe(TILE_SIZE * editor.getLineHeightInPixels() + "px")
|
||||
expect(component.tileNodesForLines()[2].style.webkitTransform).toBe(`translate3d(0px, ${component.tileNodesForLines()[0].offsetHeight + component.tileNodesForLines()[1].offsetHeight}px, 0px)`)
|
||||
})
|
||||
|
||||
it('allows the same block decoration item to be moved from one tile to another in the same animation frame', function () {
|
||||
let [item, blockDecoration] = createBlockDecorationBeforeScreenRow(5, {className: "decoration-1"})
|
||||
runAnimationFrames()
|
||||
expect(component.tileNodesForLines()[0].querySelector('.decoration-1')).toBeNull()
|
||||
expect(component.tileNodesForLines()[1].querySelector('.decoration-1')).toBe(item)
|
||||
|
||||
blockDecoration.getMarker().setHeadBufferPosition([0, 0])
|
||||
runAnimationFrames()
|
||||
expect(component.tileNodesForLines()[0].querySelector('.decoration-1')).toBe(item)
|
||||
expect(component.tileNodesForLines()[1].querySelector('.decoration-1')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('highlight decoration rendering', function () {
|
||||
@@ -2872,20 +2895,20 @@ describe('TextEditorComponent', function () {
|
||||
editor.foldBufferRange([[4, 6], [4, 10]])
|
||||
editor.foldBufferRange([[4, 15], [4, 20]])
|
||||
runAnimationFrames()
|
||||
debugger
|
||||
let foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.syntax--fold-marker')
|
||||
|
||||
let foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.fold-marker')
|
||||
expect(foldMarkers.length).toBe(2)
|
||||
expect(editor.isFoldedAtBufferRow(4)).toBe(true)
|
||||
|
||||
clickElementAtPosition(foldMarkers[0], [4, 6])
|
||||
runAnimationFrames()
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.syntax--fold-marker')
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.fold-marker')
|
||||
expect(foldMarkers.length).toBe(1)
|
||||
expect(editor.isFoldedAtBufferRow(4)).toBe(true)
|
||||
|
||||
clickElementAtPosition(foldMarkers[0], [4, 15])
|
||||
runAnimationFrames()
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.syntax--fold-marker')
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.fold-marker')
|
||||
expect(foldMarkers.length).toBe(0)
|
||||
expect(editor.isFoldedAtBufferRow(4)).toBe(false)
|
||||
})
|
||||
@@ -2895,25 +2918,25 @@ describe('TextEditorComponent', function () {
|
||||
editor.foldBufferRange([[4, 4], [4, 5]])
|
||||
editor.foldBufferRange([[4, 4], [4, 20]])
|
||||
runAnimationFrames()
|
||||
let foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.syntax--fold-marker')
|
||||
let foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.fold-marker')
|
||||
expect(foldMarkers.length).toBe(1)
|
||||
expect(editor.isFoldedAtBufferRow(4)).toBe(true)
|
||||
|
||||
clickElementAtPosition(foldMarkers[0], [4, 4])
|
||||
runAnimationFrames()
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.syntax--fold-marker')
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.fold-marker')
|
||||
expect(foldMarkers.length).toBe(1)
|
||||
expect(editor.isFoldedAtBufferRow(4)).toBe(true)
|
||||
|
||||
clickElementAtPosition(foldMarkers[0], [4, 4])
|
||||
runAnimationFrames()
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.syntax--fold-marker')
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.fold-marker')
|
||||
expect(foldMarkers.length).toBe(1)
|
||||
expect(editor.isFoldedAtBufferRow(4)).toBe(true)
|
||||
|
||||
clickElementAtPosition(foldMarkers[0], [4, 10])
|
||||
runAnimationFrames()
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.syntax--fold-marker')
|
||||
foldMarkers = component.lineNodeForScreenRow(4).querySelectorAll('.fold-marker')
|
||||
expect(foldMarkers.length).toBe(0)
|
||||
expect(editor.isFoldedAtBufferRow(4)).toBe(false)
|
||||
})
|
||||
|
||||
@@ -479,7 +479,7 @@ describe "TextEditorPresenter", ->
|
||||
|
||||
expect(getState(presenter).horizontalScrollbar.scrollWidth).toBe 10 * maxLineLength + 1
|
||||
expectStateUpdate presenter, ->
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['source.js', 'meta.method-call.js', 'support.function.js'], 'p', 20)
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['syntax--source.syntax--js', 'syntax--meta.syntax--method-call.syntax--js', 'syntax--support.syntax--function.syntax--js'], 'p', 20)
|
||||
presenter.measurementsChanged()
|
||||
expect(getState(presenter).horizontalScrollbar.scrollWidth).toBe (10 * (maxLineLength - 2)) + (20 * 2) + 1 # 2 of the characters are 20px wide now instead of 10px wide
|
||||
|
||||
@@ -766,7 +766,7 @@ describe "TextEditorPresenter", ->
|
||||
expect(getState(presenter).hiddenInput.width).toBe 15
|
||||
|
||||
expectStateUpdate presenter, ->
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['source.js', 'storage.type.var.js'], 'r', 20)
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['syntax--source.syntax--js', 'syntax--storage.syntax--type.syntax--var.syntax--js'], 'r', 20)
|
||||
presenter.measurementsChanged()
|
||||
expect(getState(presenter).hiddenInput.width).toBe 20
|
||||
|
||||
@@ -922,7 +922,7 @@ describe "TextEditorPresenter", ->
|
||||
|
||||
expect(getState(presenter).content.scrollWidth).toBe 10 * maxLineLength + 1
|
||||
expectStateUpdate presenter, ->
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['source.js', 'meta.method-call.js', 'support.function.js'], 'p', 20)
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['syntax--source.syntax--js', 'syntax--meta.syntax--method-call.syntax--js', 'syntax--support.syntax--function.syntax--js'], 'p', 20)
|
||||
presenter.measurementsChanged()
|
||||
expect(getState(presenter).content.scrollWidth).toBe (10 * (maxLineLength - 2)) + (20 * 2) + 1 # 2 of the characters are 20px wide now instead of 10px wide
|
||||
|
||||
@@ -1274,7 +1274,16 @@ describe "TextEditorPresenter", ->
|
||||
expect(tagsForCodes(presenter, lineStateForScreenRow(presenter, 0).tagCodes).openTags).toContain('invisible-character eol')
|
||||
expect(tagsForCodes(presenter, lineStateForScreenRow(presenter, 1).tagCodes).openTags).toContain('invisible-character eol')
|
||||
|
||||
describe ".blockDecorations", ->
|
||||
describe ".{preceding,following}BlockDecorations", ->
|
||||
stateForBlockDecorations = (blockDecorations) ->
|
||||
state = {}
|
||||
for blockDecoration in blockDecorations
|
||||
state[blockDecoration.id] = {
|
||||
decoration: blockDecoration,
|
||||
screenRow: blockDecoration.getMarker().getHeadScreenPosition().row
|
||||
}
|
||||
state
|
||||
|
||||
it "contains all block decorations that are present before/after a line, both initially and when decorations change", ->
|
||||
blockDecoration1 = addBlockDecorationBeforeScreenRow(0)
|
||||
presenter = buildPresenter()
|
||||
@@ -1286,32 +1295,32 @@ describe "TextEditorPresenter", ->
|
||||
blockDecoration4 = addBlockDecorationAfterScreenRow(7)
|
||||
|
||||
runs ->
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual([blockDecoration1])
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual([blockDecoration2])
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual([blockDecoration3])
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual([blockDecoration4])
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration1]))
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration2]))
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration3]))
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration4]))
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual({})
|
||||
|
||||
waitsForStateToUpdate presenter, ->
|
||||
blockDecoration1.getMarker().setHeadBufferPosition([1, 0])
|
||||
@@ -1320,32 +1329,32 @@ describe "TextEditorPresenter", ->
|
||||
blockDecoration4.getMarker().setHeadBufferPosition([8, 0])
|
||||
|
||||
runs ->
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual([blockDecoration1])
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual([blockDecoration4])
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual([blockDecoration2, blockDecoration3])
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration1]))
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration4]))
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration2, blockDecoration3]))
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual({})
|
||||
|
||||
waitsForStateToUpdate presenter, ->
|
||||
blockDecoration4.destroy()
|
||||
@@ -1353,71 +1362,85 @@ describe "TextEditorPresenter", ->
|
||||
blockDecoration1.getMarker().setHeadBufferPosition([0, 0])
|
||||
|
||||
runs ->
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual([blockDecoration1])
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual([blockDecoration2])
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration1]))
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration2]))
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual({})
|
||||
|
||||
waitsForStateToUpdate presenter, ->
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
editor.insertNewline()
|
||||
|
||||
runs ->
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual([blockDecoration1])
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual([blockDecoration2])
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual([])
|
||||
expect(lineStateForScreenRow(presenter, 0).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 0).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 1).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration1]))
|
||||
expect(lineStateForScreenRow(presenter, 1).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 2).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 3).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 3).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 5).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 6).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 7).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 7).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 8).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 8).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 9).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 9).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 10).precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration2]))
|
||||
expect(lineStateForScreenRow(presenter, 10).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 11).followingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).precedingBlockDecorations).toEqual({})
|
||||
expect(lineStateForScreenRow(presenter, 12).followingBlockDecorations).toEqual({})
|
||||
|
||||
it "inserts block decorations before the line if not specified otherwise", ->
|
||||
it "contains block decorations located in ::mouseWheelScreenRow even if they are off screen", ->
|
||||
blockDecoration = addBlockDecorationBeforeScreenRow(0)
|
||||
presenter = buildPresenter(explicitHeight: 6, scrollTop: 0, lineHeight: 1, tileSize: 2, stoppedScrollingDelay: 200)
|
||||
lineId = presenter.displayLayer.getScreenLines(0, 1)[0].id
|
||||
|
||||
expect(getState(presenter).content.tiles[0].lines[lineId].precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration]))
|
||||
|
||||
presenter.setMouseWheelScreenRow(0)
|
||||
expectStateUpdate presenter, -> presenter.setScrollTop(4)
|
||||
expect(getState(presenter).content.tiles[0].lines[lineId].precedingBlockDecorations).toEqual(stateForBlockDecorations([blockDecoration]))
|
||||
|
||||
advanceClock(presenter.stoppedScrollingDelay)
|
||||
expect(getState(presenter).content.tiles[0]).toBeUndefined()
|
||||
|
||||
it "inserts block decorations before the line unless otherwise specified", ->
|
||||
blockDecoration = editor.decorateMarker(editor.markScreenPosition([4, 0]), {type: "block"})
|
||||
presenter = buildPresenter()
|
||||
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual [blockDecoration]
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual []
|
||||
expect(lineStateForScreenRow(presenter, 4).precedingBlockDecorations).toEqual stateForBlockDecorations([blockDecoration])
|
||||
expect(lineStateForScreenRow(presenter, 4).followingBlockDecorations).toEqual {}
|
||||
|
||||
describe ".decorationClasses", ->
|
||||
it "adds decoration classes to the relevant line state objects, both initially and when decorations change", ->
|
||||
@@ -1734,12 +1757,12 @@ describe "TextEditorPresenter", ->
|
||||
presenter = buildPresenter(explicitHeight: 20)
|
||||
|
||||
expectStateUpdate presenter, ->
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['source.js', 'storage.type.var.js'], 'v', 20)
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['syntax--source.syntax--js', 'syntax--storage.syntax--type.syntax--var.syntax--js'], 'v', 20)
|
||||
presenter.measurementsChanged()
|
||||
expect(stateForCursor(presenter, 0)).toEqual {top: 1 * 10, left: (3 * 10) + 20, width: 10, height: 10}
|
||||
|
||||
expectStateUpdate presenter, ->
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['source.js', 'storage.type.var.js'], 'r', 20)
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['syntax--source.syntax--js', 'syntax--storage.syntax--type.syntax--var.syntax--js'], 'r', 20)
|
||||
presenter.measurementsChanged()
|
||||
expect(stateForCursor(presenter, 0)).toEqual {top: 1 * 10, left: (3 * 10) + 20, width: 20, height: 10}
|
||||
|
||||
@@ -2085,7 +2108,7 @@ describe "TextEditorPresenter", ->
|
||||
regions: [{top: 0, left: 4 * 10, width: 2 * 10, height: 10}]
|
||||
}
|
||||
expectStateUpdate presenter, ->
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['source.js', 'keyword.control.js'], 'i', 20)
|
||||
presenter.getLinesYardstick().setScopedCharacterWidth(['syntax--source.syntax--js', 'syntax--keyword.syntax--control.syntax--js'], 'i', 20)
|
||||
presenter.measurementsChanged()
|
||||
expectValues stateForSelectionInTile(presenter, 0, 2), {
|
||||
regions: [{top: 0, left: 4 * 10, width: 20 + 10, height: 10}]
|
||||
@@ -2208,222 +2231,112 @@ describe "TextEditorPresenter", ->
|
||||
flashCount: 2
|
||||
}
|
||||
|
||||
describe ".blockDecorations", ->
|
||||
stateForBlockDecoration = (presenter, decoration) ->
|
||||
getState(presenter).content.blockDecorations[decoration.id]
|
||||
describe ".offScreenBlockDecorations", ->
|
||||
stateForOffScreenBlockDecoration = (presenter, decoration) ->
|
||||
getState(presenter).content.offScreenBlockDecorations[decoration.id]
|
||||
|
||||
it "contains state for measured block decorations that are not visible when they are on ::mouseWheelScreenRow", ->
|
||||
blockDecoration1 = addBlockDecorationBeforeScreenRow(0)
|
||||
presenter = buildPresenter(explicitHeight: 30, lineHeight: 10, tileSize: 2, scrollTop: 0, stoppedScrollingDelay: 200)
|
||||
getState(presenter) # flush pending state
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 0)
|
||||
|
||||
presenter.setScrollTop(100)
|
||||
presenter.setMouseWheelScreenRow(0)
|
||||
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 0
|
||||
isVisible: true
|
||||
}
|
||||
|
||||
advanceClock(presenter.stoppedScrollingDelay)
|
||||
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
|
||||
it "invalidates block decorations that intersect a change in the buffer", ->
|
||||
blockDecoration1 = addBlockDecorationBeforeScreenRow(9)
|
||||
blockDecoration2 = addBlockDecorationBeforeScreenRow(10)
|
||||
blockDecoration3 = addBlockDecorationBeforeScreenRow(11)
|
||||
presenter = buildPresenter(explicitHeight: 30, lineHeight: 10, tileSize: 2, scrollTop: 0)
|
||||
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 9
|
||||
isVisible: false
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration2), {
|
||||
decoration: blockDecoration2
|
||||
screenRow: 10
|
||||
isVisible: false
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration3), {
|
||||
decoration: blockDecoration3
|
||||
screenRow: 11
|
||||
isVisible: false
|
||||
}
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 10)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration2, 0, 10)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration3, 0, 10)
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration3)).toBeUndefined()
|
||||
|
||||
editor.setSelectedScreenRange([[10, 0], [12, 0]])
|
||||
editor.delete()
|
||||
presenter.setScrollTop(0) # deleting the buffer causes the editor to autoscroll
|
||||
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration2), {
|
||||
decoration: blockDecoration2
|
||||
screenRow: 10
|
||||
isVisible: false
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration3), {
|
||||
decoration: blockDecoration3
|
||||
screenRow: 10
|
||||
isVisible: false
|
||||
}
|
||||
|
||||
it "invalidates all block decorations when content frame width, window size or bounding client rect change", ->
|
||||
blockDecoration1 = addBlockDecorationBeforeScreenRow(11)
|
||||
presenter = buildPresenter(explicitHeight: 30, lineHeight: 10, tileSize: 2, scrollTop: 0)
|
||||
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 11
|
||||
isVisible: false
|
||||
}
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 10)
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
|
||||
presenter.setBoundingClientRect({top: 0, left: 0, width: 50, height: 30})
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 11
|
||||
isVisible: false
|
||||
}
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 20)
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
|
||||
presenter.setContentFrameWidth(100)
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 11
|
||||
isVisible: false
|
||||
}
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 20)
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
|
||||
presenter.setWindowSize(100, 200)
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 11
|
||||
isVisible: false
|
||||
}
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 20)
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
|
||||
it "contains state for on-screen and unmeasured block decorations, both initially and when they are updated or destroyed", ->
|
||||
it "contains state for off-screen unmeasured block decorations, both initially and when they are updated or destroyed", ->
|
||||
item = {}
|
||||
blockDecoration1 = addBlockDecorationBeforeScreenRow(0, item)
|
||||
blockDecoration2 = addBlockDecorationBeforeScreenRow(4, item)
|
||||
blockDecoration3 = addBlockDecorationBeforeScreenRow(4, item)
|
||||
blockDecoration4 = addBlockDecorationBeforeScreenRow(10, item)
|
||||
presenter = buildPresenter(explicitHeight: 30, lineHeight: 10, tileSize: 2, scrollTop: 0)
|
||||
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 0
|
||||
isVisible: true
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration2), {
|
||||
decoration: blockDecoration2
|
||||
screenRow: 4
|
||||
isVisible: true
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration3), {
|
||||
decoration: blockDecoration3
|
||||
screenRow: 4
|
||||
isVisible: true
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration4), {
|
||||
decoration: blockDecoration4
|
||||
screenRow: 10
|
||||
isVisible: false
|
||||
}
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration3)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration4)).toBe(blockDecoration4)
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 10)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration4, 0, 20)
|
||||
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 0
|
||||
isVisible: true
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration2), {
|
||||
decoration: blockDecoration2
|
||||
screenRow: 4
|
||||
isVisible: false
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration3), {
|
||||
decoration: blockDecoration3
|
||||
screenRow: 4
|
||||
isVisible: false
|
||||
}
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration4)).toBeUndefined()
|
||||
|
||||
blockDecoration3.getMarker().setHeadScreenPosition([5, 0])
|
||||
presenter.setScrollTop(90)
|
||||
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration2), {
|
||||
decoration: blockDecoration2
|
||||
screenRow: 4
|
||||
isVisible: false
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration3), {
|
||||
decoration: blockDecoration3
|
||||
screenRow: 5
|
||||
isVisible: false
|
||||
}
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration4), {
|
||||
decoration: blockDecoration4
|
||||
screenRow: 10
|
||||
isVisible: true
|
||||
}
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBe(blockDecoration2)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration3)).toBe(blockDecoration3)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration4)).toBeUndefined()
|
||||
|
||||
presenter.invalidateBlockDecorationDimensions(blockDecoration1)
|
||||
presenter.invalidateBlockDecorationDimensions(blockDecoration4)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration2, 0, 10)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration3, 0, 10)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration3)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration4)).toBe(blockDecoration4)
|
||||
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration1), {
|
||||
decoration: blockDecoration1
|
||||
screenRow: 0
|
||||
isVisible: false
|
||||
}
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration3)).toBeUndefined()
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration4), {
|
||||
decoration: blockDecoration4
|
||||
screenRow: 10
|
||||
isVisible: true
|
||||
}
|
||||
blockDecoration4.destroy()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration3)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration4)).toBeUndefined()
|
||||
|
||||
blockDecoration1.destroy()
|
||||
it "contains state for off-screen block decorations that intersect a buffer change", ->
|
||||
blockDecoration1 = addBlockDecorationBeforeScreenRow(9)
|
||||
blockDecoration2 = addBlockDecorationBeforeScreenRow(10)
|
||||
blockDecoration3 = addBlockDecorationBeforeScreenRow(11)
|
||||
presenter = buildPresenter(explicitHeight: 30, lineHeight: 10, tileSize: 2, scrollTop: 0)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBe(blockDecoration1)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBe(blockDecoration2)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration3)).toBe(blockDecoration3)
|
||||
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
expect(stateForBlockDecoration(presenter, blockDecoration3)).toBeUndefined()
|
||||
expectValues stateForBlockDecoration(presenter, blockDecoration4), {
|
||||
decoration: blockDecoration4
|
||||
screenRow: 10
|
||||
isVisible: true
|
||||
}
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 10)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration2, 0, 10)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration3, 0, 10)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration3)).toBeUndefined()
|
||||
|
||||
editor.setSelectedScreenRange([[10, 0], [12, 0]])
|
||||
editor.delete()
|
||||
presenter.setScrollTop(0) # deleting the buffer causes the editor to autoscroll
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBe(blockDecoration2)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration3)).toBe(blockDecoration3)
|
||||
|
||||
it "contains state for all off-screen block decorations when content frame width, window size or bounding client rect change", ->
|
||||
blockDecoration1 = addBlockDecorationBeforeScreenRow(10)
|
||||
blockDecoration2 = addBlockDecorationBeforeScreenRow(11)
|
||||
presenter = buildPresenter(explicitHeight: 30, lineHeight: 10, tileSize: 2, scrollTop: 0)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBe(blockDecoration1)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBe(blockDecoration2)
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 10)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration2, 0, 10)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
|
||||
presenter.setBoundingClientRect({top: 0, left: 0, width: 50, height: 30})
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBe(blockDecoration1)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBe(blockDecoration2)
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 20)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration2, 0, 20)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
|
||||
presenter.setContentFrameWidth(100)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBe(blockDecoration1)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBe(blockDecoration2)
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 20)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration2, 0, 20)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
|
||||
presenter.setWindowSize(100, 200)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBe(blockDecoration1)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBe(blockDecoration2)
|
||||
|
||||
presenter.setBlockDecorationDimensions(blockDecoration1, 0, 20)
|
||||
presenter.setBlockDecorationDimensions(blockDecoration2, 0, 20)
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration1)).toBeUndefined()
|
||||
expect(stateForOffScreenBlockDecoration(presenter, blockDecoration2)).toBeUndefined()
|
||||
|
||||
it "doesn't throw an error when setting the dimensions for a destroyed decoration", ->
|
||||
blockDecoration = addBlockDecorationBeforeScreenRow(0)
|
||||
presenter = buildPresenter()
|
||||
|
||||
blockDecoration.destroy()
|
||||
presenter.setBlockDecorationDimensions(blockDecoration, 30, 30)
|
||||
|
||||
expect(getState(presenter).content.blockDecorations).toEqual({})
|
||||
expect(getState(presenter).content.offScreenBlockDecorations).toEqual({})
|
||||
|
||||
describe ".overlays", ->
|
||||
[item] = []
|
||||
|
||||
Reference in New Issue
Block a user