mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Clear goal range when selection is modified
Just like the cursor clears its goal column when it is moved in any way other than vertically, the selection clears its goal range (the range it will attempt to use when adding a selection below) when it is changed in any way.
This commit is contained in:
parent
7b7c77645c
commit
f22461e5e8
@ -722,7 +722,7 @@ describe "EditSession", ->
|
||||
for cursor in editSession.getCursors()
|
||||
expect(cursor.isVisible()).toBeFalsy()
|
||||
|
||||
it "honors the original selection's region when adding across shorter lines", ->
|
||||
it "honors the original selection's range (goal range) when adding across shorter lines", ->
|
||||
editSession.setSelectedBufferRange([[3, 22], [3, 38]])
|
||||
editSession.addSelectionBelow()
|
||||
editSession.addSelectionBelow()
|
||||
@ -734,6 +734,21 @@ describe "EditSession", ->
|
||||
[[6, 22], [6, 38]]
|
||||
]
|
||||
|
||||
it "clears selection goal ranges when the selection changes", ->
|
||||
editSession.setSelectedBufferRange([[3, 22], [3, 38]])
|
||||
console.log "1"
|
||||
editSession.addSelectionBelow()
|
||||
editSession.selectLeft()
|
||||
console.log "2"
|
||||
editSession.addSelectionBelow()
|
||||
editSession.addSelectionBelow()
|
||||
expect(editSession.getSelectedBufferRanges()).toEqual [
|
||||
[[3, 22], [3, 37]]
|
||||
[[4, 22], [4, 29]]
|
||||
[[5, 22], [5, 29]]
|
||||
[[6, 22], [6, 28]]
|
||||
]
|
||||
|
||||
describe "when the cursor is moved while there is a selection", ->
|
||||
makeSelection = -> selection.setBufferRange [[1, 2], [1, 5]]
|
||||
|
||||
|
@ -88,6 +88,7 @@ class Cursor
|
||||
|
||||
clearSelection: ->
|
||||
if @selection
|
||||
@selection.goalBufferRange = null
|
||||
@selection.clear() unless @selection.retainSelection
|
||||
|
||||
getScreenRow: ->
|
||||
|
@ -591,7 +591,7 @@ class EditSession
|
||||
selection = new Selection(_.extend({editSession: this, marker, cursor}, options))
|
||||
@selections.push(selection)
|
||||
selectionBufferRange = selection.getBufferRange()
|
||||
@mergeIntersectingSelections()
|
||||
@mergeIntersectingSelections() unless options.suppressMerge
|
||||
if selection.destroyed
|
||||
for selection in @getSelections()
|
||||
if selection.intersectsBufferRange(selectionBufferRange)
|
||||
|
@ -156,7 +156,7 @@ class Selection
|
||||
range = (@goalBufferRange ? @getBufferRange()).copy()
|
||||
range.start.row++
|
||||
range.end.row++
|
||||
@editSession.addSelectionForBufferRange(range, goalBufferRange: range)
|
||||
@editSession.addSelectionForBufferRange(range, goalBufferRange: range, suppressMerge: true)
|
||||
|
||||
insertText: (text, options={}) ->
|
||||
oldBufferRange = @getBufferRange()
|
||||
|
Loading…
Reference in New Issue
Block a user