diff --git a/spec/line-top-index-spec.js b/spec/line-top-index-spec.js index f2c3f9ca5..62d3e1839 100644 --- a/spec/line-top-index-spec.js +++ b/spec/line-top-index-spec.js @@ -97,7 +97,7 @@ describe("LineTopIndex", function () { expect(lineTopIndex.rowForTopPixelPosition(0)).toBe(0) expect(lineTopIndex.rowForTopPixelPosition(40)).toBe(4) expect(lineTopIndex.rowForTopPixelPosition(44)).toBe(4) - expect(lineTopIndex.rowForTopPixelPosition(46)).toBe(5) + expect(lineTopIndex.rowForTopPixelPosition(46)).toBe(4) expect(lineTopIndex.rowForTopPixelPosition(50)).toBe(5) expect(lineTopIndex.rowForTopPixelPosition(120)).toBe(12) expect(lineTopIndex.rowForTopPixelPosition(130)).toBe(12) @@ -123,7 +123,7 @@ describe("LineTopIndex", function () { expect(lineTopIndex.rowForTopPixelPosition(6)).toBe(0) expect(lineTopIndex.rowForTopPixelPosition(10)).toBe(0) expect(lineTopIndex.rowForTopPixelPosition(12)).toBe(0) - expect(lineTopIndex.rowForTopPixelPosition(17)).toBe(1) + expect(lineTopIndex.rowForTopPixelPosition(17)).toBe(0) expect(lineTopIndex.rowForTopPixelPosition(20)).toBe(1) expect(lineTopIndex.rowForTopPixelPosition(30)).toBe(2) expect(lineTopIndex.rowForTopPixelPosition(40)).toBe(3) @@ -131,10 +131,10 @@ describe("LineTopIndex", function () { expect(lineTopIndex.rowForTopPixelPosition(80)).toBe(5) expect(lineTopIndex.rowForTopPixelPosition(90)).toBe(5) expect(lineTopIndex.rowForTopPixelPosition(95)).toBe(5) - expect(lineTopIndex.rowForTopPixelPosition(105)).toBe(6) + expect(lineTopIndex.rowForTopPixelPosition(106)).toBe(5) expect(lineTopIndex.rowForTopPixelPosition(110)).toBe(6) expect(lineTopIndex.rowForTopPixelPosition(160)).toBe(11) - expect(lineTopIndex.rowForTopPixelPosition(166)).toBe(12) + expect(lineTopIndex.rowForTopPixelPosition(166)).toBe(11) expect(lineTopIndex.rowForTopPixelPosition(170)).toBe(12) expect(lineTopIndex.rowForTopPixelPosition(240)).toBe(12) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 9b6f5b78e..0e80ed113 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -191,17 +191,17 @@ describe "TextEditorPresenter", -> expect(stateFn(presenter).tiles[6].top).toBe((20 + 40) + (20 + 30) + 20 + 1) expect(stateFn(presenter).tiles[8]).toBeUndefined() - presenter.setScrollTop(22) + presenter.setScrollTop(21) expect(stateFn(presenter).tiles[0]).toBeUndefined() expect(stateFn(presenter).tiles[2].height).toBe(20 + 30) - expect(stateFn(presenter).tiles[2].top).toBe(-1) + expect(stateFn(presenter).tiles[2].top).toBe(0) expect(stateFn(presenter).tiles[4].height).toBe(20 + 40) - expect(stateFn(presenter).tiles[4].top).toBe(30 + 20 - 1) + expect(stateFn(presenter).tiles[4].top).toBe(30 + 20) expect(stateFn(presenter).tiles[6].height).toBe(20) - expect(stateFn(presenter).tiles[6].top).toBe((20 + 40) + (20 + 30) - 1) + expect(stateFn(presenter).tiles[6].top).toBe((20 + 40) + (20 + 30)) expect(stateFn(presenter).tiles[8].height).toBe(20) - expect(stateFn(presenter).tiles[8].top).toBe((20 + 40) + (20 + 30) + 20 - 1) + expect(stateFn(presenter).tiles[8].top).toBe((20 + 40) + (20 + 30) + 20) expect(stateFn(presenter).tiles[10]).toBeUndefined() it "includes state for all tiles if no external ::explicitHeight is assigned", -> diff --git a/src/linear-line-top-index.js b/src/linear-line-top-index.js index 84a3bdf04..1c7fa0503 100644 --- a/src/linear-line-top-index.js +++ b/src/linear-line-top-index.js @@ -84,7 +84,7 @@ class LineTopIndex { let nextBlocksHeight = blocksHeight + block.height let linesHeight = block.row * this.defaultLineHeight if (nextBlocksHeight + linesHeight > top) { - while (lastRow < block.row && lastTop + this.defaultLineHeight < top) { + while (lastRow < block.row && lastTop + this.defaultLineHeight <= top) { lastTop += this.defaultLineHeight lastRow++ }