diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index 71201f16e..1a75184bb 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -743,3 +743,5 @@ describe "Editor", -> expect(editor.selection.isEmpty()).toBeTruthy() expect(editor.getCursorScreenPosition()).toEqual [4, 32] + editor.setCursorScreenPosition([9, 2]) + expect(editor.getCursorScreenPosition()).toEqual [9, 2] diff --git a/spec/atom/line-wrapper-spec.coffee b/spec/atom/line-wrapper-spec.coffee index e2ba4ee9c..ba0756ae2 100644 --- a/spec/atom/line-wrapper-spec.coffee +++ b/spec/atom/line-wrapper-spec.coffee @@ -129,6 +129,7 @@ describe "LineWrapper", -> it "adjusts the position to account for the fold", -> fold = folder.createFold(new Range([4, 29], [7, 4])) expect(wrapper.screenPositionForBufferPosition([7, 4])).toEqual [5, 32] + expect(wrapper.screenPositionForBufferPosition([8, 12])).toEqual [6, 12] describe ".bufferPositionForScreenPosition(point)", -> it "translates the given screen position to a buffer position, account for wrapped lines", -> @@ -147,6 +148,7 @@ describe "LineWrapper", -> it "adjusts the position to account for the fold", -> fold = folder.createFold(new Range([4, 29], [7, 4])) expect(wrapper.bufferPositionForScreenPosition([5, 32])).toEqual [7, 4] + expect(wrapper.bufferPositionForScreenPosition([6, 12])).toEqual [8, 12] describe ".wrapScreenLine(screenLine)", -> makeTokens = (tokenValues...) -> diff --git a/src/atom/line-folder.coffee b/src/atom/line-folder.coffee index f708611eb..cc2474865 100644 --- a/src/atom/line-folder.coffee +++ b/src/atom/line-folder.coffee @@ -114,7 +114,7 @@ class LineFolder @lineMap.lineForScreenRow(screenRow) getLines: -> - @lineMap.getScreenLines() + @lineMap.screenLinesForRows(0, @lastRow()) lineCount: -> @lineMap.screenLineCount() diff --git a/src/atom/line-map.coffee b/src/atom/line-map.coffee index 6c3ae24c9..dd933d2b9 100644 --- a/src/atom/line-map.coffee +++ b/src/atom/line-map.coffee @@ -50,14 +50,10 @@ class LineMap replaceScreenRows: (start, end, screenLines) -> @spliceAtScreenRow(start, end - start + 1, screenLines) - getScreenLines: -> - return @screenLines - lineForScreenRow: (row) -> @linesForScreenRows(row, row)[0] linesForScreenRows: (startRow, endRow) -> - lastLine = null lines = [] delta = new Point @@ -67,11 +63,13 @@ class LineMap if pendingFragment pendingFragment = pendingFragment.concat(fragment) else - pendingFragment = fragment + pendingFragment = _.clone(fragment) if pendingFragment.screenDelta.row > 0 + pendingFragment.bufferDelta = new Point(1, 0) lines.push pendingFragment pendingFragment = null delta = delta.add(fragment.screenDelta) + lines lineForBufferRow: (row) -> diff --git a/src/atom/line-wrapper.coffee b/src/atom/line-wrapper.coffee index 19dd2e6c3..b0b34bd6b 100644 --- a/src/atom/line-wrapper.coffee +++ b/src/atom/line-wrapper.coffee @@ -106,11 +106,14 @@ class LineWrapper @lineMap.linesForScreenRows(startRow, endRow) getLines: -> - @linesForScreenRows(0, @lineCount() - 1) + @linesForScreenRows(0, @lastRow()) lineCount: -> @lineMap.screenLineCount() + lastRow: -> + @lineCount() - 1 + logLines: (start=0, end=@lineCount() - 1)-> @lineMap.logLines(start, end)