mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add selectToFirstCharacterOfLine to editSession
This commit is contained in:
@@ -703,6 +703,31 @@ describe "EditSession", ->
|
||||
editSession.selectWord()
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[12, 2], [12, 6]]
|
||||
|
||||
describe ".selectToFirstCharacterOfLine()", ->
|
||||
it "moves to the first character of the current line or the beginning of the line if it's already on the first character", ->
|
||||
editSession.setCursorScreenPosition [0,5]
|
||||
editSession.addCursorAtScreenPosition [1,7]
|
||||
|
||||
editSession.selectToFirstCharacterOfLine()
|
||||
|
||||
[cursor1, cursor2] = editSession.getCursors()
|
||||
expect(cursor1.getBufferPosition()).toEqual [0,0]
|
||||
expect(cursor2.getBufferPosition()).toEqual [1,2]
|
||||
|
||||
expect(editSession.getSelections().length).toBe 2
|
||||
[selection1, selection2] = editSession.getSelections()
|
||||
expect(selection1.getBufferRange()).toEqual [[0,0], [0,5]]
|
||||
expect(selection1.isReversed()).toBeTruthy()
|
||||
expect(selection2.getBufferRange()).toEqual [[1,2], [1,7]]
|
||||
expect(selection2.isReversed()).toBeTruthy()
|
||||
|
||||
editSession.selectToFirstCharacterOfLine()
|
||||
[selection1, selection2] = editSession.getSelections()
|
||||
expect(selection1.getBufferRange()).toEqual [[0,0], [0,5]]
|
||||
expect(selection1.isReversed()).toBeTruthy()
|
||||
expect(selection2.getBufferRange()).toEqual [[1,0], [1,7]]
|
||||
expect(selection2.isReversed()).toBeTruthy()
|
||||
|
||||
describe ".setSelectedBufferRanges(ranges)", ->
|
||||
it "clears existing selections and creates selections for each of the given ranges", ->
|
||||
editSession.setSelectedBufferRanges([[[2, 2], [3, 3]], [[4, 4], [5, 5]]])
|
||||
|
||||
@@ -1146,6 +1146,10 @@ class EditSession
|
||||
selectToBeginningOfLine: ->
|
||||
@expandSelectionsBackward (selection) => selection.selectToBeginningOfLine()
|
||||
|
||||
# Moves every cursor to the first non-whitespace character of the line.
|
||||
selectToFirstCharacterOfLine: ->
|
||||
@expandSelectionsBackward (selection) => selection.selectToFirstCharacterOfLine()
|
||||
|
||||
# Selects all the text from the current cursor position to the end of the line.
|
||||
selectToEndOfLine: ->
|
||||
@expandSelectionsForward (selection) => selection.selectToEndOfLine()
|
||||
|
||||
@@ -198,6 +198,10 @@ class Selection
|
||||
selectToBeginningOfLine: ->
|
||||
@modifySelection => @cursor.moveToBeginningOfLine()
|
||||
|
||||
# Selects all the text from the current cursor position to the beginning of the line.
|
||||
selectToFirstCharacterOfLine: ->
|
||||
@modifySelection => @cursor.moveToFirstCharacterOfLine()
|
||||
|
||||
# Selects all the text from the current cursor position to the end of the line.
|
||||
selectToEndOfLine: ->
|
||||
@modifySelection => @cursor.moveToEndOfLine()
|
||||
|
||||
Reference in New Issue
Block a user