Fix screen/buffer range error in paragraph cursor motions

This commit is contained in:
Max Brunsfeld
2015-04-03 10:34:21 -07:00
parent ffa6d4a9c3
commit decab183b7
2 changed files with 12 additions and 18 deletions

View File

@@ -831,35 +831,29 @@ describe "TextEditor", ->
describe ".moveToBeginningOfNextParagraph()", ->
it "moves the cursor before the first line of the next paragraph", ->
editor.setCursorBufferPosition [0,6]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [0, 6]
editor.foldBufferRow(4)
editor.moveToBeginningOfNextParagraph()
expect(cursor.getBufferPosition()).toEqual { row : 10, column : 0 }
expect(editor.getCursorBufferPosition()).toEqual [10, 0]
editor.setText("")
editor.setCursorBufferPosition [0,0]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [0, 0]
editor.moveToBeginningOfNextParagraph()
expect(cursor.getBufferPosition()).toEqual [0, 0]
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
describe ".moveToBeginningOfPreviousParagraph()", ->
it "moves the cursor before the first line of the pevious paragraph", ->
editor.setCursorBufferPosition [10,0]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [10, 0]
editor.foldBufferRow(4)
editor.moveToBeginningOfPreviousParagraph()
expect(cursor.getBufferPosition()).toEqual { row : 0, column : 0 }
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
editor.setText("")
editor.setCursorBufferPosition [0,0]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [0, 0]
editor.moveToBeginningOfPreviousParagraph()
expect(cursor.getBufferPosition()).toEqual [0, 0]
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
describe ".getCurrentParagraphBufferRange()", ->
it "returns the buffer range of the current paragraph, delimited by blank lines or the beginning / end of the file", ->

View File

@@ -672,7 +672,7 @@ class Cursor extends Model
if !range.start.isEqual(start)
position = range.start
stop()
@editor.screenPositionForBufferPosition(position)
position
getBeginningOfPreviousParagraphBufferPosition: ->
start = @getBufferPosition()
@@ -685,4 +685,4 @@ class Cursor extends Model
if !range.start.isEqual(zero)
position = range.start
stop()
@editor.screenPositionForBufferPosition(position)
position