mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Use buffer instead of line map for EditSession.clipBufferPosition(position)
This commit is contained in:
@@ -1234,3 +1234,9 @@ describe "EditSession", ->
|
||||
editSession.foldAll()
|
||||
expect(editSession.getCursorBufferPosition()).toEqual([5,5])
|
||||
|
||||
|
||||
describe ".clipBufferPosition(bufferPosition)", ->
|
||||
it "clips the given position to a valid position", ->
|
||||
expect(editSession.clipBufferPosition([-1, -1])).toEqual [0,0]
|
||||
expect(editSession.clipBufferPosition([Infinity, Infinity])).toEqual [12,2]
|
||||
expect(editSession.clipBufferPosition([8, 57])).toEqual [8, 56]
|
||||
|
||||
@@ -87,7 +87,13 @@ class EditSession
|
||||
@renderer.clipScreenPosition(screenPosition, options)
|
||||
|
||||
clipBufferPosition: (bufferPosition, options) ->
|
||||
@renderer.clipBufferPosition(bufferPosition, options)
|
||||
{ row, column } = Point.fromObject(bufferPosition)
|
||||
row = 0 if row < 0
|
||||
column = 0 if column < 0
|
||||
row = Math.min(@buffer.getLastRow(), row)
|
||||
column = Math.min(@buffer.lineLengthForRow(row), column)
|
||||
|
||||
new Point(row, column)
|
||||
|
||||
getEofBufferPosition: ->
|
||||
@buffer.getEofPosition()
|
||||
|
||||
@@ -81,9 +81,6 @@ class LineMap
|
||||
clipScreenPosition: (screenPosition, options) ->
|
||||
@clipPosition('screenDelta', screenPosition, options)
|
||||
|
||||
clipBufferPosition: (bufferPosition, options) ->
|
||||
@clipPosition('bufferDelta', bufferPosition, options)
|
||||
|
||||
clipPosition: (deltaType, position, options={}) ->
|
||||
options.clipToBounds = true
|
||||
@translatePosition(deltaType, deltaType, position, options)
|
||||
|
||||
@@ -165,9 +165,6 @@ class Renderer
|
||||
clipScreenPosition: (position, options) ->
|
||||
@lineMap.clipScreenPosition(position, options)
|
||||
|
||||
clipBufferPosition: (position, options) ->
|
||||
@lineMap.clipBufferPosition(position, options)
|
||||
|
||||
handleBufferChange: (e) ->
|
||||
allFolds = [] # Folds can modify @activeFolds, so first make sure we have a stable array of folds
|
||||
allFolds.push(folds...) for row, folds of @activeFolds
|
||||
|
||||
Reference in New Issue
Block a user