This commit is contained in:
Antonio Scandurra
2015-09-23 10:15:38 +02:00
parent 25735b2ee1
commit 0ccb34de42
2 changed files with 21 additions and 21 deletions

View File

@@ -3412,6 +3412,13 @@ describe "TextEditorComponent", ->
expect(wrapperNode.getScrollBottom()).toBe (7 + editor.getVerticalScrollMargin()) * 10
expect(wrapperNode.getScrollRight()).toBe (8 + editor.getHorizontalScrollMargin()) * 10
describe "when adding selections for buffer ranges", ->
it "autoscrolls to the added selection if needed", ->
editor.addSelectionForBufferRange([[8, 10], [8, 15]])
nextAnimationFrame()
expect(wrapperNode.getScrollBottom()).toBe (9 * 10) + (2 * 10)
expect(wrapperNode.getScrollRight()).toBe (15 * 10) + (2 * 10)
describe "when selecting lines containing cursors", ->
it "autoscrolls to the selection", ->
editor.setCursorScreenPosition([5, 6])
@@ -3425,6 +3432,20 @@ describe "TextEditorComponent", ->
nextAnimationFrame()
expect(wrapperNode.getScrollBottom()).toBe (7 + editor.getVerticalScrollMargin()) * 10
describe "when inserting text", ->
describe "when there are multiple empty selections on different lines", ->
it "autoscrolls to the last cursor", ->
editor.setCursorScreenPosition([1, 2], autoscroll: false)
nextAnimationFrame()
editor.addCursorAtScreenPosition([10, 4], autoscroll: false)
nextAnimationFrame()
expect(wrapperNode.getScrollTop()).toBe 0
editor.insertText('a')
nextAnimationFrame()
expect(wrapperNode.getScrollTop()).toBe 75
describe "moving cursors", ->
it "scrolls down when the last cursor gets closer than ::verticalScrollMargin to the bottom of the editor", ->
expect(wrapperNode.getScrollTop()).toBe 0

View File

@@ -1465,17 +1465,6 @@ describe "TextEditor", ->
editor.addSelectionForBufferRange([[3, 4], [5, 6]])
expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [0, 0]], [[3, 4], [5, 6]]]
it "autoscrolls to the added selection if needed", ->
editor.setVerticalScrollMargin(2)
editor.setHorizontalScrollMargin(2)
editor.setLineHeightInPixels(10)
editor.setDefaultCharWidth(10)
editor.setHeight(80)
editor.setWidth(100)
editor.addSelectionForBufferRange([[8, 10], [8, 15]])
expect(editor.getScrollBottom()).toBe (9 * 10) + (2 * 10)
expect(editor.getScrollRight()).toBe (15 * 10) + (2 * 10)
describe ".addSelectionBelow()", ->
describe "when the selection is non-empty", ->
it "selects the same region of the line below current selections if possible", ->
@@ -1826,16 +1815,6 @@ describe "TextEditor", ->
expect(cursor1.getBufferPosition()).toEqual [1, 5]
expect(cursor2.getBufferPosition()).toEqual [2, 7]
it "autoscrolls to the last cursor", ->
editor.setCursorScreenPosition([1, 2])
editor.addCursorAtScreenPosition([10, 4])
editor.setLineHeightInPixels(10)
editor.setHeight(50)
expect(editor.getScrollTop()).toBe 0
editor.insertText('a')
expect(editor.getScrollTop()).toBe 80
describe "when there are multiple non-empty selections", ->
describe "when the selections are on the same line", ->
it "replaces each selection range with the inserted characters", ->