From decab183b7ddef217ed0ecd58875915f81c31c79 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 3 Apr 2015 10:34:21 -0700 Subject: [PATCH] Fix screen/buffer range error in paragraph cursor motions --- spec/text-editor-spec.coffee | 26 ++++++++++---------------- src/cursor.coffee | 4 ++-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 51226a22b..439a1ddb6 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -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", -> diff --git a/src/cursor.coffee b/src/cursor.coffee index acfc7fc9e..1656b9dc2 100644 --- a/src/cursor.coffee +++ b/src/cursor.coffee @@ -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