Remove unused eagerWrap option from position translation

This commit is contained in:
Nathan Sobo
2012-02-29 12:19:16 -07:00
parent 775cc1add2
commit 634b90d17a
6 changed files with 12 additions and 28 deletions

View File

@@ -346,7 +346,7 @@ describe "LineFolder", ->
expect(folder.bufferPositionForScreenPosition([4, 13])).toEqual [4, 15]
expect(folder.bufferPositionForScreenPosition([4, 18])).toEqual [4, 20]
describe ".clipScreenPosition(screenPosition, eagerWrap=false)", ->
describe ".clipScreenPosition(screenPosition)", ->
beforeEach ->
folder.createFold(new Range([4, 29], [7, 4]))
@@ -373,6 +373,3 @@ describe "LineFolder", ->
expect(folder.clipScreenPosition([4, 31], skipAtomicTokens: true)).toEqual [4, 32]
expect(folder.clipScreenPosition([4, 32], skipAtomicTokens: true)).toEqual [4, 32]

View File

@@ -150,7 +150,7 @@ describe "LineMap", ->
expect(map.lineForBufferRow(0).text).toBe line0.text
expect(map.lineForBufferRow(1).text).toBe line1Text
describe ".screenPositionForBufferPosition(bufferPosition, eagerWrap=true)", ->
describe ".screenPositionForBufferPosition(bufferPosition)", ->
beforeEach ->
# line1a-line3b describes a fold
[line1a, line1b] = line1.splitAt(10)
@@ -172,14 +172,8 @@ describe "LineMap", ->
expect(map.screenPositionForBufferPosition([3, 30])).toEqual [1, 20]
expect(map.screenPositionForBufferPosition([4, 5])).toEqual [2, 5]
describe "when eagerWrap is false", ->
it "does not wrap buffer positions at the end of a screen line to the beginning of the next screen line", ->
expect(map.screenPositionForBufferPosition([4, 20], false)).toEqual [2, 20]
expect(map.screenPositionForBufferPosition([4, 29], false)).toEqual [3, 9]
describe "when eagerWrap is true", ->
it "wraps buffer positions at the end of a screen line to the end end of the next screen line", ->
expect(map.screenPositionForBufferPosition([4, 20], true)).toEqual [3, 0]
it "wraps buffer positions at the end of a screen line to the end end of the next screen line", ->
expect(map.screenPositionForBufferPosition([4, 20])).toEqual [3, 0]
describe ".screenLineCount()", ->
it "returns the total of all inserted screen row deltas", ->

View File

@@ -103,7 +103,7 @@ describe "LineWrapper", ->
expect(event.oldRange).toEqual([[0, 0], [15, 2]])
expect(event.newRange).toEqual([[0, 0], [18, 2]])
describe ".screenPositionForBufferPosition(point, eagerWrap=true)", ->
describe ".screenPositionForBufferPosition(point)", ->
it "translates the given buffer position to a screen position, accounting for wrapped lines", ->
# before any wrapped lines
expect(wrapper.screenPositionForBufferPosition([0, 5])).toEqual([0, 5])
@@ -117,13 +117,8 @@ describe "LineWrapper", ->
# following a wrapped line
expect(wrapper.screenPositionForBufferPosition([4, 5])).toEqual([5, 5])
describe "when eagerWrap is false", ->
it "preserves a position at the end of a wrapped screen line ", ->
expect(wrapper.screenPositionForBufferPosition([3, 51], false)).toEqual([3, 51])
describe "when eagerWrap is true", ->
it "translates a position at the end of a wrapped screen line to the begining of the next screen line", ->
expect(wrapper.screenPositionForBufferPosition([3, 51], true)).toEqual([4, 0])
it "translates a position at the end of a wrapped screen line to the begining of the next screen line", ->
expect(wrapper.screenPositionForBufferPosition([3, 51], true)).toEqual([4, 0])
describe "when the position follows a fold", ->
it "adjusts the position to account for the fold", ->

View File

@@ -228,8 +228,8 @@ class Editor extends View
else
$(window).off 'resize', @_setMaxLineLength
clipScreenPosition: (screenPosition, eagerWrap=false) ->
@lineWrapper.clipScreenPosition(screenPosition, eagerWrap)
clipScreenPosition: (screenPosition, options={}) ->
@lineWrapper.clipScreenPosition(screenPosition, options)
pixelPositionForScreenPosition: ({row, column}) ->
{ top: row * @lineHeight, left: column * @charWidth }

View File

@@ -99,7 +99,7 @@ class LineMap
lastScreenRow: ->
@screenLineCount() - 1
screenPositionForBufferPosition: (bufferPosition, eagerWrap=true) ->
screenPositionForBufferPosition: (bufferPosition) ->
bufferPosition = Point.fromObject(bufferPosition)
bufferDelta = new Point
screenDelta = new Point
@@ -107,7 +107,6 @@ class LineMap
for lineFragment in @lineFragments
nextDelta = bufferDelta.add(lineFragment.bufferDelta)
break if nextDelta.isGreaterThan(bufferPosition)
break if nextDelta.isEqual(bufferPosition) and not eagerWrap
bufferDelta = nextDelta
screenDelta = screenDelta.add(lineFragment.screenDelta)

View File

@@ -76,10 +76,9 @@ class LineWrapper
return column + 1 if /\s/.test(line[column])
return @maxLength
screenPositionForBufferPosition: (bufferPosition, eagerWrap=true) ->
screenPositionForBufferPosition: (bufferPosition) ->
@lineMap.screenPositionForBufferPosition(
@lineFolder.screenPositionForBufferPosition(bufferPosition),
eagerWrap)
@lineFolder.screenPositionForBufferPosition(bufferPosition))
bufferPositionForScreenPosition: (screenPosition) ->
@lineFolder.bufferPositionForScreenPosition(