diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 199075197..035cddcc9 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -2195,6 +2195,49 @@ describe "TextEditorPresenter", -> expect(stateForBlockDecoration(presenter, blockDecoration1)).toBeUndefined() + it "invalidates all block decorations when content frame width, window size or bounding client rect change", -> + blockDecoration1 = editor.addBlockDecorationForScreenRow(11, null) + 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 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-component.coffee b/src/block-decorations-component.coffee index c154b85c6..e9d80f2aa 100644 --- a/src/block-decorations-component.coffee +++ b/src/block-decorations-component.coffee @@ -12,14 +12,17 @@ class BlockDecorationsComponent @domNode = @domElementPool.buildElement("content") @domNode.setAttribute("select", ".atom--invisible-block-decoration") @domNode.style.visibility = "hidden" - @domNode.style.position = "absolute" getDomNode: -> @domNode updateSync: (state) -> @newState = state.content - @oldState ?= {blockDecorations: {}} + @oldState ?= {blockDecorations: {}, width: 0} + + if @newState.width isnt @oldState.width + @domNode.style.width = @newState.width + "px" + @oldState.width = @newState.width for id, blockDecorationState of @oldState.blockDecorations unless @newState.blockDecorations.hasOwnProperty(id) diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index 1d2c0bcdc..1fcb21123 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -89,7 +89,7 @@ class TextEditorComponent @scrollViewNode.appendChild(@linesComponent.getDomNode()) if @blockDecorationsComponent? - @scrollViewNode.appendChild(@blockDecorationsComponent.getDomNode()) + @linesComponent.getDomNode().appendChild(@blockDecorationsComponent.getDomNode()) @linesYardstick = new LinesYardstick(@editor, @linesComponent, lineTopIndex, @grammars) @presenter.setLinesYardstick(@linesYardstick) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 46a575e55..f11027b22 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -921,12 +921,15 @@ class TextEditorPresenter @editorWidthInChars = null @updateScrollbarDimensions() @updateClientWidth() + @invalidateAllBlockDecorationsDimensions = true @shouldUpdateDecorations = true @emitDidUpdateState() setBoundingClientRect: (boundingClientRect) -> unless @clientRectsEqual(@boundingClientRect, boundingClientRect) @boundingClientRect = boundingClientRect + @invalidateAllBlockDecorationsDimensions = true + @shouldUpdateDecorations = true @emitDidUpdateState() clientRectsEqual: (clientRectA, clientRectB) -> @@ -940,6 +943,8 @@ class TextEditorPresenter if @windowWidth isnt width or @windowHeight isnt height @windowWidth = width @windowHeight = height + @invalidateAllBlockDecorationsDimensions = true + @shouldUpdateDecorations = true @emitDidUpdateState()