mirror of
https://github.com/atom/atom.git
synced 2026-01-26 23:38:48 -05:00
🐛 Coordinate conversion is hard
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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", ->
|
||||
|
||||
@@ -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++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user