mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Always restore marker ranges on undo/redo, even for valid markers
This commit is contained in:
parent
f48ee846e9
commit
988f4da6e1
@ -1027,6 +1027,13 @@ describe 'TextBuffer', ->
|
||||
buffer.undo()
|
||||
expect(marker1.getRange()).toEqual [[4, 23], [4, 26]]
|
||||
|
||||
it "restores the marker range exactly on undo", ->
|
||||
marker = buffer.markRange([[3, 0], [3, 62]])
|
||||
buffer.delete([[2, 0], [3, 0]])
|
||||
expect(marker.getRange()).toEqual [[2, 0], [2, 62]]
|
||||
buffer.undo()
|
||||
expect(marker.getRange()).toEqual [[3, 0], [3, 62]]
|
||||
|
||||
describe "when the change follows the marker range", ->
|
||||
it "does not move the marker", ->
|
||||
buffer.insert([6, 5], '...')
|
||||
|
@ -100,7 +100,7 @@ class BufferChangeOperation
|
||||
newRange
|
||||
|
||||
invalidateMarkers: (oldRange) ->
|
||||
_.compact(@buffer.getMarkers().map (marker) -> marker.tryToInvalidate(oldRange))
|
||||
@buffer.getMarkers().map (marker) -> marker.tryToInvalidate(oldRange)
|
||||
|
||||
pauseMarkerObservation: ->
|
||||
marker.pauseEvents() for marker in @buffer.getMarkers(includeInvalid: true)
|
||||
|
@ -182,26 +182,21 @@ class BufferMarker
|
||||
betweenStartAndEnd = @getRange().containsRange(changedRange, exclusive: false)
|
||||
containsStart = changedRange.containsPoint(@getStartPosition(), exclusive: true)
|
||||
containsEnd = changedRange.containsPoint(@getEndPosition(), exclusive: true)
|
||||
|
||||
previousRange = @getRange()
|
||||
switch @invalidationStrategy
|
||||
when 'between'
|
||||
if betweenStartAndEnd or containsStart or containsEnd
|
||||
@invalidate()
|
||||
[@id]
|
||||
@invalidate() if betweenStartAndEnd or containsStart or containsEnd
|
||||
when 'contains'
|
||||
if containsStart or containsEnd
|
||||
@invalidate()
|
||||
[@id]
|
||||
@invalidate() if containsStart or containsEnd
|
||||
when 'never'
|
||||
if containsStart or containsEnd
|
||||
previousRange = @getRange()
|
||||
if containsStart and containsEnd
|
||||
@setRange([changedRange.end, changedRange.end])
|
||||
else if containsStart
|
||||
@setRange([changedRange.end, @getEndPosition()])
|
||||
else
|
||||
@setRange([@getStartPosition(), changedRange.start])
|
||||
[@id, previousRange]
|
||||
[@id, previousRange]
|
||||
|
||||
handleBufferChange: (bufferChange) ->
|
||||
@consolidateObserverNotifications true, =>
|
||||
|
Loading…
Reference in New Issue
Block a user