Skip to content

Instantly share code, notes, and snippets.

View kashms's full-sized avatar
🤖

Kash Qureshi kashms

🤖
  • Microsoft
  • NYC
View GitHub Profile
// Function to revert from a stack
function revertFromStack(stack: Revertible[]): void {
const revertible = stack.pop();
if (revertible !== undefined) {
revertible.revert();
}
}
// 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);
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
{
"todo": [
{ "id": 1, "text": "buy milk" },
- { "id": 2, "text": "feed cat" },
+ { "id": 2, "text": "feed Loki" },
{ "id": 3, "text": "buy eggs" }
]
}
{
"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" }
]
}
{
"todo": [
{ "id": 1, "text": "buy milk" },
{ "id": 3, "text": "buy eggs" },
{ "id": 2, "text": "feed Loki" }
]
}
{
"todo": [
{ "id": 1, "text": "buy milk" },
{ "id": 2, "text": "feed Loki" },
{ "id": 3, "text": "buy eggs" }
]
}
{
"todo": [
{ "id": 1, "text": "buy milk" },
{ "id": 3, "text": "buy eggs" },
{ "id": 2, "text": "feed cat" }
]
}
{
"todo": [
{ "id": 1, "text": "buy milk" },
{ "id": 2, "text": "feed cat" },
{ "id": 3, "text": "buy eggs" }
]
}