Buffer updates anchors when it changes instead of EditSession

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-07-13 17:42:41 -06:00
parent 9eae88e97b
commit 926067164d
6 changed files with 41 additions and 16 deletions

View File

@@ -140,6 +140,15 @@ class Buffer
operation = new BufferChangeOperation({buffer: this, oldRange, newText})
@pushOperation(operation)
clipPosition: (position) ->
{ row, column } = Point.fromObject(position)
row = 0 if row < 0
column = 0 if column < 0
row = Math.min(@getLastRow(), row)
column = Math.min(@lineLengthForRow(row), column)
new Point(row, column)
prefixAndSuffixForRange: (range) ->
prefix: @lines[range.start.row][0...range.start.column]
suffix: @lines[range.end.row][range.end.column..]
@@ -179,6 +188,8 @@ class Buffer
isModified: ->
@modified
getAnchors: -> new Array(@anchors...)
addAnchor: (options) ->
anchor = new Anchor(this, options)
@anchors.push(anchor)