Fold placeholder lines are treated as if they're empty

This commit is contained in:
Nathan Sobo
2012-05-21 19:20:18 -07:00
parent 6387f512c7
commit 74008ab329
3 changed files with 13 additions and 7 deletions

View File

@@ -395,6 +395,10 @@ describe "Renderer", ->
expect(renderer.clipScreenPosition([0, 30], wrapBeyondNewlines: true)).toEqual [1, 0]
expect(renderer.clipScreenPosition([0, 1000], wrapBeyondNewlines: true)).toEqual [1, 0]
it "wraps positions in the middle of fold lines to the next screen line", ->
renderer.createFold(3, 5)
expect(renderer.clipScreenPosition([3, 5], wrapBeyondNewlines: true)).toEqual [4, 0]
describe "when wrapAtSoftNewlines is false (the default)", ->
it "clips positions at the end of soft-wrapped lines to the character preceding the end of the line", ->
expect(renderer.clipScreenPosition([3, 50])).toEqual [3, 50]

View File

@@ -121,8 +121,8 @@ class LineMap
targetDelta = traversalResult[targetDeltaType]
return targetDelta unless lastLineFragment
maxSourceColumn = sourceDelta.column + lastLineFragment.text.length
maxTargetColumn = targetDelta.column + lastLineFragment.text.length
maxSourceColumn = sourceDelta.column + lastLineFragment.textLength()
maxTargetColumn = targetDelta.column + lastLineFragment.textLength()
if lastLineFragment.isSoftWrapped() and sourcePosition.column >= maxSourceColumn
if wrapAtSoftNewlines

View File

@@ -49,11 +49,7 @@ class ScreenLineFragment
translateColumn: (sourceDeltaType, targetDeltaType, sourceColumn, options={}) ->
{ skipAtomicTokens } = options
if @fold
textLength = 0
else
textLength = @text.length
sourceColumn = Math.min(sourceColumn, textLength)
sourceColumn = Math.min(sourceColumn, @textLength())
currentSourceColumn = 0
currentTargetColumn = 0
@@ -75,6 +71,12 @@ class ScreenLineFragment
remainingColumns = sourceColumn - currentSourceColumn
currentTargetColumn + remainingColumns
textLength: ->
if @fold
textLength = 0
else
textLength = @text.length
isSoftWrapped: ->
@screenDelta.row == 1 and @bufferDelta.row == 0