mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-10-27 11:42:41 +03:00
Port leftover specs from DisplayBuffer
This commit is contained in:
parent
270334b713
commit
99e77dc09d
@ -718,21 +718,6 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.clipScreenPosition([0, 1], clip: 'forward')).toEqual [0, tabLength]
|
||||
expect(displayBuffer.clipScreenPosition([0, tabLength], clip: 'forward')).toEqual [0, tabLength]
|
||||
|
||||
describe "::screenPositionForPixelPosition(pixelPosition)", ->
|
||||
it "clips pixel positions above buffer start", ->
|
||||
displayBuffer.setLineHeightInPixels(20)
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: -Infinity)).toEqual [0, 0]
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: Infinity)).toEqual [0, 0]
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: -1, left: Infinity)).toEqual [0, 0]
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: 0, left: Infinity)).toEqual [0, 29]
|
||||
|
||||
it "clips pixel positions below buffer end", ->
|
||||
displayBuffer.setLineHeightInPixels(20)
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: -Infinity)).toEqual [12, 2]
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: Infinity)).toEqual [12, 2]
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: displayBuffer.getHeight() + 1, left: 0)).toEqual [12, 2]
|
||||
expect(displayBuffer.screenPositionForPixelPosition(top: displayBuffer.getHeight() - 1, left: 0)).toEqual [12, 0]
|
||||
|
||||
describe "::screenPositionForBufferPosition(bufferPosition, options)", ->
|
||||
it "clips the specified buffer position", ->
|
||||
expect(displayBuffer.screenPositionForBufferPosition([0, 2])).toEqual [0, 2]
|
||||
@ -1247,32 +1232,6 @@ describe "DisplayBuffer", ->
|
||||
expect(scrollSpy).toHaveBeenCalledWith(screenRange: [[8, 20], [8, 20]], options: {center: true})
|
||||
expect(scrollSpy).toHaveBeenCalledWith(screenRange: [[8, 20], [8, 20]], options: {center: false, reversed: true})
|
||||
|
||||
describe "::getVisibleRowRange()", ->
|
||||
beforeEach ->
|
||||
displayBuffer.setLineHeightInPixels(10)
|
||||
displayBuffer.setHeight(100)
|
||||
|
||||
it "returns the first and the last visible rows", ->
|
||||
displayBuffer.setScrollTop(0)
|
||||
|
||||
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 9]
|
||||
|
||||
it "includes partially visible rows in the range", ->
|
||||
displayBuffer.setScrollTop(5)
|
||||
|
||||
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 10]
|
||||
|
||||
it "returns an empty range when lineHeight is 0", ->
|
||||
displayBuffer.setLineHeightInPixels(0)
|
||||
|
||||
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 0]
|
||||
|
||||
it "ends at last buffer row even if there's more space available", ->
|
||||
displayBuffer.setHeight(150)
|
||||
displayBuffer.setScrollTop(60)
|
||||
|
||||
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 13]
|
||||
|
||||
describe "::decorateMarker", ->
|
||||
describe "when decorating gutters", ->
|
||||
[marker] = []
|
||||
|
@ -3605,6 +3605,40 @@ describe "TextEditorComponent", ->
|
||||
nextAnimationFrame()
|
||||
expect(wrapperNode.getScrollTop()).toBe 0
|
||||
|
||||
describe "::screenPositionForPixelPosition(pixelPosition)", ->
|
||||
it "clips pixel positions above buffer start", ->
|
||||
expect(component.screenPositionForPixelPosition(top: -Infinity, left: -Infinity)).toEqual [0, 0]
|
||||
expect(component.screenPositionForPixelPosition(top: -Infinity, left: Infinity)).toEqual [0, 0]
|
||||
expect(component.screenPositionForPixelPosition(top: -1, left: Infinity)).toEqual [0, 0]
|
||||
expect(component.screenPositionForPixelPosition(top: 0, left: Infinity)).toEqual [0, 29]
|
||||
|
||||
it "clips pixel positions below buffer end", ->
|
||||
expect(component.screenPositionForPixelPosition(top: Infinity, left: -Infinity)).toEqual [12, 2]
|
||||
expect(component.screenPositionForPixelPosition(top: Infinity, left: Infinity)).toEqual [12, 2]
|
||||
expect(component.screenPositionForPixelPosition(top: component.getScrollHeight() + 1, left: 0)).toEqual [12, 2]
|
||||
expect(component.screenPositionForPixelPosition(top: component.getScrollHeight() - 1, left: 0)).toEqual [12, 0]
|
||||
|
||||
describe "::getVisibleRowRange()", ->
|
||||
beforeEach ->
|
||||
wrapperNode.style.height = lineHeightInPixels * 8 + "px"
|
||||
component.measureDimensions()
|
||||
nextAnimationFrame()
|
||||
|
||||
it "returns the first and the last visible rows", ->
|
||||
component.setScrollTop(0)
|
||||
nextAnimationFrame()
|
||||
|
||||
expect(component.getVisibleRowRange()).toEqual [0, 9]
|
||||
|
||||
it "ends at last buffer row even if there's more space available", ->
|
||||
wrapperNode.style.height = lineHeightInPixels * 13 + "px"
|
||||
component.measureDimensions()
|
||||
nextAnimationFrame()
|
||||
|
||||
component.setScrollTop(60)
|
||||
nextAnimationFrame()
|
||||
|
||||
expect(component.getVisibleRowRange()).toEqual [0, 13]
|
||||
|
||||
describe "middle mouse paste on Linux", ->
|
||||
originalPlatform = null
|
||||
|
Loading…
Reference in New Issue
Block a user