mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
wip
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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", ->
|
||||
|
||||
Reference in New Issue
Block a user