diff --git a/spec/app/display-buffer-spec.coffee b/spec/app/display-buffer-spec.coffee index b59c44fdd..fb98d6272 100644 --- a/spec/app/display-buffer-spec.coffee +++ b/spec/app/display-buffer-spec.coffee @@ -513,6 +513,13 @@ describe "DisplayBuffer", -> expect(displayBuffer.clipScreenPosition([0, 1], skipAtomicTokens: true)).toEqual [0, tabLength] expect(displayBuffer.clipScreenPosition([0, tabLength], skipAtomicTokens: true)).toEqual [0, tabLength] + describe ".screenPositionForBufferPosition(bufferPosition, options)", -> + it "clips the specified buffer position", -> + expect(displayBuffer.screenPositionForBufferPosition([0, 2])).toEqual [0, 2] + expect(displayBuffer.screenPositionForBufferPosition([0, 100000])).toEqual [0, 29] + expect(displayBuffer.screenPositionForBufferPosition([100000, 0])).toEqual [12, 2] + expect(displayBuffer.screenPositionForBufferPosition([100000, 100000])).toEqual [12, 2] + describe "position translation in the presence of hard tabs", -> it "correctly translates positions on either side of a tab", -> buffer.setText('\t') diff --git a/src/app/display-buffer.coffee b/src/app/display-buffer.coffee index d97e81021..55f22ba42 100644 --- a/src/app/display-buffer.coffee +++ b/src/app/display-buffer.coffee @@ -241,7 +241,7 @@ class DisplayBuffer # # Returns a {Point}. screenPositionForBufferPosition: (bufferPosition, options) -> - { row, column } = Point.fromObject(bufferPosition) + { row, column } = @buffer.clipPosition(bufferPosition) [startScreenRow, endScreenRow] = @rowMap.screenRowRangeForBufferRow(row) for screenRow in [startScreenRow...endScreenRow] screenLine = @screenLines[screenRow]