Handle 'autoscroll' option in model when setting selected buffer range

This commit is contained in:
Nathan Sobo
2014-04-17 15:24:40 -06:00
parent dd4b6a6d28
commit a0ff6f5325
5 changed files with 85 additions and 39 deletions

View File

@@ -76,8 +76,9 @@ class Selection extends Model
options.reversed ?= @isReversed()
@editor.destroyFoldsIntersectingBufferRange(bufferRange) unless options.preserveFolds
@modifySelection =>
@cursor.needsAutoscroll = false if options.autoscroll?
@cursor.needsAutoscroll = false if @needsAutoscroll?
@marker.setBufferRange(bufferRange, options)
@autoscroll() if @needsAutoscroll
# Public: Returns the starting and ending buffer rows the selection is
# highlighting.
@@ -90,6 +91,9 @@ class Selection extends Model
end = Math.max(start, end - 1) if range.end.column == 0
[start, end]
autoscroll: ->
@editor.autoscrollToScreenRange(@getScreenRange())
# Public: Returns the text in the selection.
getText: ->
@editor.buffer.getTextInRange(@getBufferRange())