mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add selectToBufferPosition
This commit is contained in:
@@ -925,6 +925,18 @@ describe "Editor", ->
|
||||
expect(selection1.getScreenRange()).toEqual([[0, 9], [1, 21]])
|
||||
expect(selection1.isReversed()).toBeFalsy()
|
||||
|
||||
describe ".selectToBufferPosition(bufferPosition)", ->
|
||||
it "expands the last selection to the given position", ->
|
||||
editor.setSelectedBufferRange([[3, 0], [4, 5]])
|
||||
editor.addCursorAtBufferPosition([5, 6])
|
||||
editor.selectToBufferPosition([6, 2])
|
||||
|
||||
selections = editor.getSelections()
|
||||
expect(selections.length).toBe 2
|
||||
[selection1, selection2] = selections
|
||||
expect(selection1.getBufferRange()).toEqual [[3, 0], [4, 5]]
|
||||
expect(selection2.getBufferRange()).toEqual [[5, 6], [6, 2]]
|
||||
|
||||
describe ".selectToScreenPosition(screenPosition)", ->
|
||||
it "expands the last selection to the given position", ->
|
||||
editor.setSelectedBufferRange([[3, 0], [4, 5]])
|
||||
|
||||
@@ -1923,6 +1923,17 @@ class Editor extends Model
|
||||
selection.autoscroll() if @manageScrollPosition
|
||||
selection
|
||||
|
||||
# Essential: Select from the current cursor position to the given position in
|
||||
# buffer coordinates.
|
||||
#
|
||||
# This method may merge selections that end up intesecting.
|
||||
#
|
||||
# * `position` An instance of {Point}, with a given `row` and `column`.
|
||||
selectToBufferPosition: (position) ->
|
||||
lastSelection = @getLastSelection()
|
||||
lastSelection.selectToBufferPosition(position)
|
||||
@mergeIntersectingSelections(reversed: lastSelection.isReversed())
|
||||
|
||||
# Essential: Select from the current cursor position to the given position in
|
||||
# screen coordinates.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user