mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Pass selectionsMarkerLayer on transact, undo and redo
To restore selections of change initiated editor on undo/redo.
This commit is contained in:
@@ -224,7 +224,7 @@ class TextEditor {
|
||||
|
||||
this.defaultMarkerLayer = this.displayLayer.addMarkerLayer()
|
||||
if (!this.selectionsMarkerLayer) {
|
||||
this.selectionsMarkerLayer = this.addMarkerLayer({maintainHistory: true, persistent: true})
|
||||
this.selectionsMarkerLayer = this.addMarkerLayer({maintainHistory: true, persistent: true, role: 'selections'})
|
||||
}
|
||||
|
||||
this.decorationManager = new DecorationManager(this)
|
||||
@@ -1808,13 +1808,13 @@ class TextEditor {
|
||||
|
||||
// Essential: Undo the last change.
|
||||
undo () {
|
||||
this.avoidMergingSelections(() => this.buffer.undo())
|
||||
this.avoidMergingSelections(() => this.buffer.undo({selectionsMarkerLayer: this.selectionsMarkerLayer}))
|
||||
this.getLastSelection().autoscroll()
|
||||
}
|
||||
|
||||
// Essential: Redo the last change.
|
||||
redo () {
|
||||
this.avoidMergingSelections(() => this.buffer.redo())
|
||||
this.avoidMergingSelections(() => this.buffer.redo({selectionsMarkerLayer: this.selectionsMarkerLayer}))
|
||||
this.getLastSelection().autoscroll()
|
||||
}
|
||||
|
||||
@@ -1831,7 +1831,13 @@ class TextEditor {
|
||||
// still 'groupable', the two transactions are merged with respect to undo and redo.
|
||||
// * `fn` A {Function} to call inside the transaction.
|
||||
transact (groupingInterval, fn) {
|
||||
return this.buffer.transact(groupingInterval, fn)
|
||||
const options = {selectionsMarkerLayer: this.selectionsMarkerLayer}
|
||||
if (typeof groupingInterval === 'function') {
|
||||
fn = groupingInterval
|
||||
} else {
|
||||
options.groupingInterval = groupingInterval
|
||||
}
|
||||
return this.buffer.transact(options, fn)
|
||||
}
|
||||
|
||||
// Extended: Abort an open transaction, undoing any operations performed so far
|
||||
@@ -1842,7 +1848,9 @@ class TextEditor {
|
||||
// with {::revertToCheckpoint} and {::groupChangesSinceCheckpoint}.
|
||||
//
|
||||
// Returns a checkpoint value.
|
||||
createCheckpoint () { return this.buffer.createCheckpoint() }
|
||||
createCheckpoint () {
|
||||
return this.buffer.createCheckpoint({selectionsMarkerLayer: this.selectionsMarkerLayer})
|
||||
}
|
||||
|
||||
// Extended: Revert the buffer to the state it was in when the given
|
||||
// checkpoint was created.
|
||||
@@ -1866,7 +1874,9 @@ class TextEditor {
|
||||
// * `checkpoint` The checkpoint from which to group changes.
|
||||
//
|
||||
// Returns a {Boolean} indicating whether the operation succeeded.
|
||||
groupChangesSinceCheckpoint (checkpoint) { return this.buffer.groupChangesSinceCheckpoint(checkpoint) }
|
||||
groupChangesSinceCheckpoint (checkpoint) {
|
||||
return this.buffer.groupChangesSinceCheckpoint(checkpoint, {selectionsMarkerLayer: this.selectionsMarkerLayer})
|
||||
}
|
||||
|
||||
/*
|
||||
Section: TextEditor Coordinates
|
||||
|
||||
Reference in New Issue
Block a user