diff --git a/spec/atom/line-wrapper-spec.coffee b/spec/atom/line-wrapper-spec.coffee index 48bf7b59f..710409fc3 100644 --- a/spec/atom/line-wrapper-spec.coffee +++ b/spec/atom/line-wrapper-spec.coffee @@ -47,11 +47,11 @@ fdescribe "LineWrapper", -> expect(segments[2].endColumn).toBe 65 expect(_.pluck(segments[2], 'value').join('')).toBe 'right.push(current);' - xdescribe ".tokensForScreenRow(row)", -> + describe ".tokensForScreenRow(row)", -> it "returns tokens for the line fragment corresponding to the given screen row", -> - expect(buffer.tokensForScreenRow(3)).toEqual(wrapper.segmentsForRow(3)[0]) - expect(buffer.tokensForScreenRow(4)).toEqual(wrapper.segmentsForRow(3)[1]) - expect(buffer.tokensForScreenRow(5)).toEqual(wrapper.segmentsForRow(4)[0]) + expect(wrapper.tokensForScreenRow(3)).toEqual(wrapper.segmentsForRow(3)[0]) + expect(wrapper.tokensForScreenRow(4)).toEqual(wrapper.segmentsForRow(3)[1]) + expect(wrapper.tokensForScreenRow(5)).toEqual(wrapper.segmentsForRow(4)[0]) describe ".screenPositionFromBufferPosition(point)", -> it "translates the given buffer position to a screen position, accounting for wrapped lines", -> diff --git a/src/atom/line-wrapper.coffee b/src/atom/line-wrapper.coffee index afdebeba5..5e8ffd90b 100644 --- a/src/atom/line-wrapper.coffee +++ b/src/atom/line-wrapper.coffee @@ -69,7 +69,6 @@ class LineWrapper new Point(row, column) - bufferPositionFromScreenPosition: (screenPosition) -> screenPosition = Point.fromObject(screenPosition) bufferRow = 0 @@ -81,3 +80,9 @@ class LineWrapper currentScreenRow++ bufferRow++ + tokensForScreenRow: (screenRow) -> + currentScreenRow = 0 + for screenLines in @lines + for screenLine in screenLines + return screenLine if currentScreenRow == screenRow + currentScreenRow++