This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to revert from a stack | |
function revertFromStack(stack: Revertible[]): void { | |
const revertible = stack.pop(); | |
if (revertible !== undefined) { | |
revertible.revert(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Subscribe to the commitApplied event | |
treeView.events.on( | |
"commitApplied", | |
(commit: CommitMetadata, getRevertible?: RevertibleFactory): void => { | |
if (getRevertible === undefined) { | |
return; | |
} | |
const revertible = getRevertible(); | |
if (commit.kind === CommitKind.Undo) { | |
redoStack.push(revertible); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public deleteGroup() { | |
const parent = Tree.parent(this); | |
if (Tree.is(parent, Items)) { | |
// Wrap these operations as a transaction | |
Tree.runTransaction(parent, () => { | |
// Move the children of the group to the parent | |
const index = parent.indexOf(this); | |
parent.moveRangeToIndex(index, 0, this.items.length, this.items); | |
// Remove the now empty group |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"todo": [ | |
{ "id": 1, "text": "buy milk" }, | |
- { "id": 2, "text": "feed cat" }, | |
+ { "id": 2, "text": "feed Loki" }, | |
{ "id": 3, "text": "buy eggs" } | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"todo": [ | |
{ "id": 1, "text": "buy milk" }, | |
- { "id": 2, "text": "feed cat" }, | |
- { "id": 3, "text": "buy eggs" } | |
+ { "id": 3, "text": "buy eggs" }, | |
+ { "id": 2, "text": "feed cat" } | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"todo": [ | |
{ "id": 1, "text": "buy milk" }, | |
{ "id": 3, "text": "buy eggs" }, | |
{ "id": 2, "text": "feed Loki" } | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"todo": [ | |
{ "id": 1, "text": "buy milk" }, | |
{ "id": 2, "text": "feed Loki" }, | |
{ "id": 3, "text": "buy eggs" } | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"todo": [ | |
{ "id": 1, "text": "buy milk" }, | |
{ "id": 3, "text": "buy eggs" }, | |
{ "id": 2, "text": "feed cat" } | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"todo": [ | |
{ "id": 1, "text": "buy milk" }, | |
{ "id": 2, "text": "feed cat" }, | |
{ "id": 3, "text": "buy eggs" } | |
] | |
} |