Editor selects text that was typed at a tab-stop when shift-tabbing back to it

This commit is contained in:
Nathan Sobo
2012-06-26 17:55:40 -06:00
parent 65991c686a
commit 01993f1be2
4 changed files with 18 additions and 13 deletions

View File

@@ -7,7 +7,7 @@ class AnchorRange
constructor: (@editSession, bufferRange) ->
bufferRange = Range.fromObject(bufferRange)
@startAnchor = @editSession.addAnchorAtBufferPosition(bufferRange.start)
@startAnchor = @editSession.addAnchorAtBufferPosition(bufferRange.start, ignoreEqual: true)
@endAnchor = @editSession.addAnchorAtBufferPosition(bufferRange.end)
getBufferRange: ->
@@ -18,4 +18,4 @@ class AnchorRange
destroy: ->
@startAnchor.destroy()
@endAnchor.destroy()
@endAnchor.destroy()

View File

@@ -8,12 +8,17 @@ class Anchor
bufferPosition: null
screenPosition: null
constructor: (@editSession) ->
constructor: (@editSession, options = {}) ->
{ @ignoreEqual } = options
handleBufferChange: (e) ->
{ oldRange, newRange } = e
position = @getBufferPosition()
return if position.isLessThan(oldRange.end)
if @ignoreEqual
return if position.isLessThanOrEqual(oldRange.end)
else
return if position.isLessThan(oldRange.end)
newRow = newRange.end.row
newColumn = newRange.end.column

View File

@@ -237,13 +237,13 @@ class EditSession
getAnchors: ->
new Array(@anchors...)
addAnchor: ->
anchor = new Anchor(this)
addAnchor: (options) ->
anchor = new Anchor(this, options)
@anchors.push(anchor)
anchor
addAnchorAtBufferPosition: (bufferPosition) ->
anchor = @addAnchor()
addAnchorAtBufferPosition: (bufferPosition, options) ->
anchor = @addAnchor(options)
anchor.setBufferPosition(bufferPosition)
anchor