mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Pass clipping options in setting screen position and translating buffer position for screen position
This allows Cursor.proto.moveRight to avoid pre-clipping its position. It just passes the appropriate clipping options when setting its screen position.
This commit is contained in:
@@ -44,8 +44,8 @@ class Anchor
|
||||
position = Point.fromObject(position)
|
||||
clip = options.clip ? true
|
||||
|
||||
@screenPosition = if clip then @editor.clipScreenPosition(position) else position
|
||||
@bufferPosition = @editor.bufferPositionForScreenPosition(position)
|
||||
@screenPosition = if clip then @editor.clipScreenPosition(position, options) else position
|
||||
@bufferPosition = @editor.bufferPositionForScreenPosition(position, options)
|
||||
|
||||
Object.freeze @screenPosition
|
||||
Object.freeze @bufferPosition
|
||||
Object.freeze @bufferPosition
|
||||
|
||||
@@ -148,7 +148,7 @@ class Cursor extends View
|
||||
|
||||
moveRight: ->
|
||||
{ row, column } = @getScreenPosition()
|
||||
@setScreenPosition(@editor.clipScreenPosition([row, column + 1], skipAtomicTokens: true, wrapBeyondNewlines: true, wrapAtSoftNewlines: true))
|
||||
@setScreenPosition([row, column + 1], skipAtomicTokens: true, wrapBeyondNewlines: true, wrapAtSoftNewlines: true)
|
||||
|
||||
moveLeft: ->
|
||||
{ row, column } = @getScreenPosition()
|
||||
|
||||
@@ -333,8 +333,8 @@ class Editor extends View
|
||||
screenPositionForBufferPosition: (position) ->
|
||||
@renderer.screenPositionForBufferPosition(position)
|
||||
|
||||
bufferPositionForScreenPosition: (position) ->
|
||||
@renderer.bufferPositionForScreenPosition(position)
|
||||
bufferPositionForScreenPosition: (position, options) ->
|
||||
@renderer.bufferPositionForScreenPosition(position, options)
|
||||
|
||||
screenRangeForBufferRange: (range) ->
|
||||
@renderer.screenRangeForBufferRange(range)
|
||||
|
||||
@@ -57,8 +57,8 @@ class LineMap
|
||||
screenPositionForBufferPosition: (bufferPosition) ->
|
||||
@translatePosition('bufferDelta', 'screenDelta', bufferPosition)
|
||||
|
||||
bufferPositionForScreenPosition: (screenPosition) ->
|
||||
@translatePosition('screenDelta', 'bufferDelta', screenPosition)
|
||||
bufferPositionForScreenPosition: (screenPosition, options) ->
|
||||
@translatePosition('screenDelta', 'bufferDelta', screenPosition, options)
|
||||
|
||||
screenRangeForBufferRange: (bufferRange) ->
|
||||
bufferRange = Range.fromObject(bufferRange)
|
||||
@@ -116,6 +116,7 @@ class LineMap
|
||||
@clipToBounds(sourceDeltaType, sourcePosition) if clipToBounds
|
||||
traversalResult = @traverseByDelta(sourceDeltaType, sourcePosition)
|
||||
lastLineFragment = traversalResult.lastLineFragment
|
||||
traversedAllFragments = traversalResult.traversedAllFragments
|
||||
sourceDelta = traversalResult[sourceDeltaType]
|
||||
targetDelta = traversalResult[targetDeltaType]
|
||||
|
||||
@@ -130,7 +131,7 @@ class LineMap
|
||||
else
|
||||
targetDelta.column = maxTargetColumn - 1
|
||||
return @clipPosition(targetDeltaType, targetDelta)
|
||||
else if sourcePosition.column > maxSourceColumn and wrapBeyondNewlines
|
||||
else if sourcePosition.column > maxSourceColumn and wrapBeyondNewlines and not traversedAllFragments
|
||||
targetDelta.row++
|
||||
targetDelta.column = 0
|
||||
else
|
||||
@@ -157,14 +158,16 @@ class LineMap
|
||||
screenDelta = new Point
|
||||
bufferDelta = new Point
|
||||
|
||||
for lineFragment in @lineFragments
|
||||
for lineFragment, index in @lineFragments
|
||||
iterator({ lineFragment, screenDelta, bufferDelta }) if traversalDelta.isGreaterThanOrEqual(startPosition) and iterator?
|
||||
traversalDelta = traversalDelta.add(lineFragment[deltaType])
|
||||
break if traversalDelta.isGreaterThan(endPosition)
|
||||
screenDelta = screenDelta.add(lineFragment.screenDelta)
|
||||
bufferDelta = bufferDelta.add(lineFragment.bufferDelta)
|
||||
|
||||
{ screenDelta, bufferDelta, lastLineFragment: lineFragment }
|
||||
lastLineFragment = lineFragment
|
||||
traversedAllFragments = (index == @lineFragments.length - 1)
|
||||
{ screenDelta, bufferDelta, lastLineFragment, traversedAllFragments }
|
||||
|
||||
logLines: (start=0, end=@screenLineCount() - 1)->
|
||||
for row in [start..end]
|
||||
|
||||
@@ -103,8 +103,8 @@ class Renderer
|
||||
screenPositionForBufferPosition: (position) ->
|
||||
@lineMap.screenPositionForBufferPosition(position)
|
||||
|
||||
bufferPositionForScreenPosition: (position) ->
|
||||
@lineMap.bufferPositionForScreenPosition(position)
|
||||
bufferPositionForScreenPosition: (position, options) ->
|
||||
@lineMap.bufferPositionForScreenPosition(position, options)
|
||||
|
||||
clipScreenPosition: (position, options={}) ->
|
||||
@lineMap.clipScreenPosition(position, options)
|
||||
|
||||
Reference in New Issue
Block a user