mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
@@ -1220,6 +1220,21 @@ describe "Editor", ->
|
||||
expect(editor.selectMarker(marker)).toBeFalsy()
|
||||
expect(editor.getSelectedBufferRange()).toEqual [[0, 0], [0, 0]]
|
||||
|
||||
describe ".addSelectionForBufferRange(bufferRange)", ->
|
||||
it "adds a selection for the specified buffer range", ->
|
||||
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.setLineHeightInPixels(10)
|
||||
editor.setDefaultCharWidth(10)
|
||||
editor.setHeight(50)
|
||||
editor.setWidth(50)
|
||||
|
||||
editor.addSelectionForBufferRange([[8, 10], [8, 15]])
|
||||
expect(editor.getScrollTop()).toBe 75
|
||||
expect(editor.getScrollLeft()).toBe 160
|
||||
|
||||
describe ".addSelectionBelow()", ->
|
||||
describe "when the selection is non-empty", ->
|
||||
it "selects the same region of the line below current selections if possible", ->
|
||||
|
||||
@@ -1278,7 +1278,9 @@ class Editor extends Model
|
||||
# Returns the added {Selection}.
|
||||
addSelectionForBufferRange: (bufferRange, options={}) ->
|
||||
@markBufferRange(bufferRange, _.defaults(@getSelectionMarkerAttributes(), options))
|
||||
@getLastSelection()
|
||||
selection = @getLastSelection()
|
||||
selection.autoscroll()
|
||||
selection
|
||||
|
||||
# Public: Set the selected range in buffer coordinates. If there are multiple
|
||||
# selections, they are reduced to a single selection with the given range.
|
||||
|
||||
Reference in New Issue
Block a user