diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 1ae540005..fa2f1ea4f 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -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) diff --git a/src/block-decorations-presenter.js b/src/block-decorations-presenter.js index 9964f3eb9..51944e584 100644 --- a/src/block-decorations-presenter.js +++ b/src/block-decorations-presenter.js @@ -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}) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 2a869045f..78bc67a08 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -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}