mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
Do not remove invisible decorations on ::mouseWheelScreenRow
This commit is contained in:
@@ -2103,6 +2103,25 @@ describe "TextEditorPresenter", ->
|
||||
stateForBlockDecoration = (presenter, decoration) ->
|
||||
presenter.getState().content.blockDecorations[decoration.id]
|
||||
|
||||
it "contains state for measured block decorations that are not visible when they are on ::mouseWheelScreenRow", ->
|
||||
blockDecoration1 = editor.addBlockDecorationForScreenRow(0, null)
|
||||
presenter = buildPresenter(explicitHeight: 30, lineHeight: 10, tileSize: 2, scrollTop: 0, stoppedScrollingDelay: 200)
|
||||
presenter.getState() # 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 "contains state for block decorations, indicating the screen row they belong to both initially and when their markers move", ->
|
||||
item = {}
|
||||
blockDecoration1 = editor.addBlockDecorationForScreenRow(0, item)
|
||||
|
||||
@@ -75,13 +75,14 @@ class BlockDecorationsPresenter {
|
||||
return blocks.map((block) => this.decorationsByBlock.get(block.id)).filter((decoration) => decoration)
|
||||
}
|
||||
|
||||
decorationsForScreenRowRange (startRow, endRow) {
|
||||
decorationsForScreenRowRange (startRow, endRow, mouseWheelScreenRow) {
|
||||
let blocks = this.lineTopIndex.allBlocks()
|
||||
let decorationsByScreenRow = new Map()
|
||||
for (let block of blocks) {
|
||||
let decoration = this.decorationsByBlock.get(block.id)
|
||||
let hasntMeasuredDecoration = !this.measuredDecorations.has(decoration)
|
||||
let isVisible = startRow <= block.row && block.row < endRow
|
||||
let isWithinVisibleRange = startRow <= block.row && block.row < endRow
|
||||
let isVisible = isWithinVisibleRange || block.row === mouseWheelScreenRow
|
||||
if (decoration && (isVisible || hasntMeasuredDecoration)) {
|
||||
let decorations = decorationsByScreenRow.get(block.row) || []
|
||||
decorations.push({decoration, isVisible})
|
||||
|
||||
@@ -1208,7 +1208,7 @@ class TextEditorPresenter
|
||||
|
||||
startRow = @getStartTileRow()
|
||||
endRow = @getEndTileRow() + @tileSize
|
||||
decorations = @blockDecorationsPresenter.decorationsForScreenRowRange(startRow, endRow)
|
||||
decorations = @blockDecorationsPresenter.decorationsForScreenRowRange(startRow, endRow, @mouseWheelScreenRow)
|
||||
decorations.forEach (decorations, screenRow) =>
|
||||
for {decoration, isVisible} in decorations
|
||||
@state.content.blockDecorations[decoration.id] = {decoration, screenRow, isVisible}
|
||||
|
||||
Reference in New Issue
Block a user