diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index d214201fa..2c090cd4d 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -1663,7 +1663,7 @@ describe('TextEditorComponent', function () { atom.themes.removeStylesheet('test') }) - it("renders visible and yet-to-be-measured block decorations, inserting them in the appropriate spots between lines and refreshing them when needed", async function () { + it("renders visible and yet-to-be-measured block decorations, inserting them between the appropriate lines and refreshing them as needed", async function () { wrapperNode.style.height = 9 * lineHeightInPixels + 'px' component.measureDimensions() await nextViewUpdatePromise() diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index fa2f1ea4f..a07c3446b 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -1320,11 +1320,11 @@ describe "TextEditorPresenter", -> expect(lineStateForScreenRow(presenter, 12).blockDecorations).toEqual([]) waitsForStateToUpdate presenter, -> - blockDecoration1.destroy() blockDecoration3.destroy() + blockDecoration1.getMarker().setHeadBufferPosition([0, 0]) runs -> - expect(lineStateForScreenRow(presenter, 0).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 0).blockDecorations).toEqual([blockDecoration1]) expect(lineStateForScreenRow(presenter, 1).blockDecorations).toEqual([]) expect(lineStateForScreenRow(presenter, 2).blockDecorations).toEqual([]) expect(lineStateForScreenRow(presenter, 3).blockDecorations).toEqual([]) @@ -1338,6 +1338,25 @@ describe "TextEditorPresenter", -> expect(lineStateForScreenRow(presenter, 11).blockDecorations).toEqual([]) expect(lineStateForScreenRow(presenter, 12).blockDecorations).toEqual([]) + waitsForStateToUpdate presenter, -> + editor.setCursorBufferPosition([0, 0]) + editor.insertNewline() + + runs -> + expect(lineStateForScreenRow(presenter, 0).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 1).blockDecorations).toEqual([blockDecoration1]) + expect(lineStateForScreenRow(presenter, 2).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 3).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 4).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 5).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 6).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 7).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 8).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 9).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 10).blockDecorations).toEqual([blockDecoration2]) + expect(lineStateForScreenRow(presenter, 11).blockDecorations).toEqual([]) + expect(lineStateForScreenRow(presenter, 12).blockDecorations).toEqual([]) + describe ".decorationClasses", -> it "adds decoration classes to the relevant line state objects, both initially and when decorations change", -> marker1 = editor.addMarkerLayer(maintainHistory: true).markBufferRange([[4, 0], [6, 2]], invalidate: 'touch') @@ -1551,10 +1570,11 @@ describe "TextEditorPresenter", -> blockDecoration1 = editor.addBlockDecorationForScreenRow(0) blockDecoration2 = editor.addBlockDecorationForScreenRow(1) - presenter.setBlockDecorationDimensions(blockDecoration1, 0, 30) - presenter.setBlockDecorationDimensions(blockDecoration2, 0, 10) - waitsForStateToUpdate presenter + waitsForStateToUpdate presenter, -> + presenter.setBlockDecorationDimensions(blockDecoration1, 0, 30) + presenter.setBlockDecorationDimensions(blockDecoration2, 0, 10) + runs -> expect(stateForCursor(presenter, 0)).toEqual {top: 50, left: 2 * 10, width: 10, height: 10} expect(stateForCursor(presenter, 1)).toEqual {top: 60, left: 4 * 10, width: 10, height: 10} @@ -1562,6 +1582,15 @@ describe "TextEditorPresenter", -> expect(stateForCursor(presenter, 3)).toBeUndefined() expect(stateForCursor(presenter, 4)).toBeUndefined() + waitsForStateToUpdate presenter, -> + blockDecoration2.destroy() + editor.setCursorBufferPosition([0, 0]) + editor.insertNewline() + editor.setCursorBufferPosition([0, 0]) + + runs -> + expect(stateForCursor(presenter, 0)).toEqual {top: 0, left: 0, width: 10, height: 10} + it "updates when ::scrollTop changes", -> editor.setSelectedBufferRanges([ [[1, 2], [1, 2]], diff --git a/src/lines-tile-component.coffee b/src/lines-tile-component.coffee index 73e88aa32..24c05dc2e 100644 --- a/src/lines-tile-component.coffee +++ b/src/lines-tile-component.coffee @@ -127,14 +127,14 @@ class LinesTileComponent delete @insertionPointsByLineId[id] insertBlockDecorationInsertionPoint: (id) -> - {hasBlockDecorations} = @newTileState.lines[id] + {hasBlockDecorations, screenRow} = @newTileState.lines[id] if hasBlockDecorations lineNode = @lineNodesByLineId[id] insertionPoint = @domElementPool.buildElement("content") @domNode.insertBefore(insertionPoint, lineNode) @insertionPointsByLineId[id] = insertionPoint - + insertionPoint.dataset.screenRow = screenRow @updateBlockDecorationInsertionPoint(id) updateBlockDecorationInsertionPoint: (id) ->