mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Bring in @nathansobo PR changes
...as they were needed to pass specs
This commit is contained in:
@@ -196,7 +196,7 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.bufferPositionForScreenPosition([3, 5])).toEqual([3, 5])
|
||||
expect(displayBuffer.screenPositionForBufferPosition([3, 50])).toEqual([3, 50])
|
||||
expect(displayBuffer.screenPositionForBufferPosition([3, 51])).toEqual([3, 50])
|
||||
expect(displayBuffer.bufferPositionForScreenPosition([4, 0])).toEqual([3, 51])
|
||||
expect(displayBuffer.bufferPositionForScreenPosition([4, 0])).toEqual([3, 50])
|
||||
expect(displayBuffer.bufferPositionForScreenPosition([3, 50])).toEqual([3, 50])
|
||||
expect(displayBuffer.screenPositionForBufferPosition([3, 62])).toEqual([4, 15])
|
||||
expect(displayBuffer.bufferPositionForScreenPosition([4, 11])).toEqual([3, 58])
|
||||
@@ -671,7 +671,7 @@ describe "DisplayBuffer", ->
|
||||
displayBuffer.setSoftWrapped(true)
|
||||
displayBuffer.setEditorWidthInChars(10)
|
||||
expect(displayBuffer.screenPositionForBufferPosition([0, 10], wrapAtSoftNewlines: true)).toEqual [1, 4]
|
||||
expect(displayBuffer.bufferPositionForScreenPosition([1, 0])).toEqual [0, 10]
|
||||
expect(displayBuffer.bufferPositionForScreenPosition([1, 0])).toEqual [0, 9]
|
||||
|
||||
describe "::getMaxLineLength()", ->
|
||||
it "returns the length of the longest screen line", ->
|
||||
|
||||
@@ -287,7 +287,7 @@ describe "TextEditor", ->
|
||||
|
||||
it "positions the cursor at the buffer position that corresponds to the given screen position", ->
|
||||
editor.setCursorScreenPosition([9, 0])
|
||||
expect(editor.getCursorBufferPosition()).toEqual [8, 11]
|
||||
expect(editor.getCursorBufferPosition()).toEqual [8, 10]
|
||||
|
||||
describe ".moveUp()", ->
|
||||
it "moves the cursor up", ->
|
||||
|
||||
@@ -359,19 +359,21 @@ class Cursor extends Model
|
||||
# line.
|
||||
moveToFirstCharacterOfLine: ->
|
||||
screenRow = @getScreenRow()
|
||||
lineBufferRange = @editor.bufferRangeForScreenRange([[screenRow, 0], [screenRow, Infinity]])
|
||||
screenLineStart = @editor.clipScreenPosition([screenRow, 0], wrapAtSoftNewlines: true)
|
||||
screenLineEnd = [screenRow, Infinity]
|
||||
screenLineBufferRange = @editor.bufferRangeForScreenRange([screenLineStart, screenLineEnd])
|
||||
|
||||
firstCharacterColumn = null
|
||||
@editor.scanInBufferRange /\S/, lineBufferRange, ({range, stop}) ->
|
||||
@editor.scanInBufferRange /\S/, screenLineBufferRange, ({range, stop}) ->
|
||||
firstCharacterColumn = range.start.column
|
||||
stop()
|
||||
|
||||
if firstCharacterColumn? and firstCharacterColumn isnt @getBufferColumn()
|
||||
targetBufferColumn = firstCharacterColumn
|
||||
else
|
||||
targetBufferColumn = lineBufferRange.start.column
|
||||
targetBufferColumn = screenLineBufferRange.start.column
|
||||
|
||||
@setBufferPosition([lineBufferRange.start.row, targetBufferColumn])
|
||||
@setBufferPosition([screenLineBufferRange.start.row, targetBufferColumn])
|
||||
|
||||
# Public: Moves the cursor to the end of the line.
|
||||
moveToEndOfScreenLine: ->
|
||||
|
||||
Reference in New Issue
Block a user