mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
@@ -255,9 +255,11 @@ describe "EditSession", ->
|
||||
expect(cursor1.getBufferPosition()).toEqual [0,0]
|
||||
expect(cursor2.getBufferPosition()).toEqual [1,0]
|
||||
|
||||
it "does not throw an exception on an empty line", ->
|
||||
editSession.setCursorBufferPosition([10, 0])
|
||||
editSession.moveCursorToFirstCharacterOfLine()
|
||||
describe "when triggered ", ->
|
||||
it "does not move the cursor", ->
|
||||
editSession.setCursorBufferPosition([10, 0])
|
||||
editSession.moveCursorToFirstCharacterOfLine()
|
||||
expect(editSession.getCursorBufferPosition()).toEqual [10, 0]
|
||||
|
||||
describe ".moveCursorToBeginningOfWord()", ->
|
||||
it "moves the cursor to the beginning of the word", ->
|
||||
|
||||
@@ -106,4 +106,4 @@ describe 'File', ->
|
||||
changeHandler.reset()
|
||||
|
||||
waitsFor "change event", ->
|
||||
changeHandler.callCount > 0
|
||||
changeHandler.callCount > 0
|
||||
|
||||
1
spec/fixtures/git/working-dir/file.txt
vendored
1
spec/fixtures/git/working-dir/file.txt
vendored
@@ -1 +0,0 @@
|
||||
Full of text
|
||||
@@ -133,11 +133,11 @@ class Buffer
|
||||
lineLengthForRow: (row) ->
|
||||
@lines[row].length
|
||||
|
||||
rangeForRow: (row) ->
|
||||
if row == @getLastRow()
|
||||
new Range([row, 0], [row, @lineLengthForRow(row)])
|
||||
else
|
||||
rangeForRow: (row, { includeNewline } = {}) ->
|
||||
if includeNewline and row < @getLastRow()
|
||||
new Range([row, 0], [row + 1, 0])
|
||||
else
|
||||
new Range([row, 0], [row, @lineLengthForRow(row)])
|
||||
|
||||
getLineCount: ->
|
||||
@getLines().length
|
||||
|
||||
@@ -106,7 +106,8 @@ class Cursor
|
||||
|
||||
moveToFirstCharacterOfLine: ->
|
||||
position = @getBufferPosition()
|
||||
range = @editSession.bufferRangeForBufferRow(position.row)
|
||||
range = @getCurrentLineBufferRange()
|
||||
console.log range.inspect()
|
||||
newPosition = null
|
||||
@editSession.scanInRange /^\s*/, range, (match, matchRange) =>
|
||||
newPosition = matchRange.end
|
||||
@@ -116,7 +117,7 @@ class Cursor
|
||||
|
||||
skipLeadingWhitespace: ->
|
||||
position = @getBufferPosition()
|
||||
range = @editSession.bufferRangeForBufferRow(position.row)
|
||||
range = @getCurrentLineBufferRange()
|
||||
endOfLeadingWhitespace = null
|
||||
@editSession.scanInRange /^[ \t]*/, range, (match, matchRange) =>
|
||||
endOfLeadingWhitespace = matchRange.end
|
||||
@@ -161,8 +162,8 @@ class Cursor
|
||||
getCurrentWordBufferRange: ->
|
||||
new Range(@getBeginningOfCurrentWordBufferPosition(allowPrevious: false), @getEndOfCurrentWordBufferPosition(allowNext: false))
|
||||
|
||||
getCurrentLineBufferRange: ->
|
||||
@editSession.bufferRangeForBufferRow(@getBufferRow())
|
||||
getCurrentLineBufferRange: (options) ->
|
||||
@editSession.bufferRangeForBufferRow(@getBufferRow(), options)
|
||||
|
||||
getCurrentWordPrefix: ->
|
||||
@editSession.getTextInBufferRange([@getBeginningOfCurrentWordBufferPosition(), @getBufferPosition()])
|
||||
|
||||
@@ -139,7 +139,7 @@ class EditSession
|
||||
nextNonBlankBufferRow: (bufferRow) -> @buffer.nextNonBlankRow(bufferRow)
|
||||
getEofBufferPosition: -> @buffer.getEofPosition()
|
||||
getLastBufferRow: -> @buffer.getLastRow()
|
||||
bufferRangeForBufferRow: (row) -> @buffer.rangeForRow(row)
|
||||
bufferRangeForBufferRow: (row, options) -> @buffer.rangeForRow(row, options)
|
||||
lineForBufferRow: (row) -> @buffer.lineForRow(row)
|
||||
scanInRange: (args...) -> @buffer.scanInRange(args...)
|
||||
backwardsScanInRange: (args...) -> @buffer.backwardsScanInRange(args...)
|
||||
|
||||
@@ -99,19 +99,15 @@ class Selection
|
||||
@setBufferRange(@getBufferRange().union(@cursor.getCurrentWordBufferRange()))
|
||||
|
||||
selectLine: (row=@cursor.getBufferPosition().row) ->
|
||||
startPosition = [row, 0]
|
||||
if @editSession.getLastBufferRow() == row
|
||||
endPosition = [row, Infinity]
|
||||
else
|
||||
endPosition = [row+1, 0]
|
||||
@setBufferRange [startPosition, endPosition]
|
||||
|
||||
range = @editSession.bufferRangeForBufferRow(row, includeNewline: true)
|
||||
@setBufferRange(range)
|
||||
@linewise = true
|
||||
@wordwise = false
|
||||
@initialScreenRange = @getScreenRange()
|
||||
|
||||
expandOverLine: ->
|
||||
@setBufferRange(@getBufferRange().union(@cursor.getCurrentLineBufferRange()))
|
||||
range = @getBufferRange().union(@cursor.getCurrentLineBufferRange(includeNewline: true))
|
||||
@setBufferRange(range)
|
||||
|
||||
selectToScreenPosition: (position) ->
|
||||
@modifySelection =>
|
||||
|
||||
Reference in New Issue
Block a user