fix: remove extra snapshots when double clicking a card
parent
35067f824e
commit
30eefb5279
11
src/main.zig
11
src/main.zig
|
@ -475,9 +475,13 @@ pub fn doSelectOrPlace(pressed: bool) !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cards_moved) {
|
||||||
try history.append(gpa, snapshot);
|
try history.append(gpa, snapshot);
|
||||||
|
}
|
||||||
|
|
||||||
selected_deck = null;
|
selected_deck = null;
|
||||||
} else {
|
} else {
|
||||||
|
var cards_moved = false;
|
||||||
const snapshot = try Snapshot.initFromCurrentGlobalState();
|
const snapshot = try Snapshot.initFromCurrentGlobalState();
|
||||||
if (selected_deck) |selected| move_from_selected_to_hovered: {
|
if (selected_deck) |selected| move_from_selected_to_hovered: {
|
||||||
const selected_substack = selected.items[selected_card..];
|
const selected_substack = selected.items[selected_card..];
|
||||||
|
@ -492,7 +496,7 @@ pub fn doSelectOrPlace(pressed: bool) !void {
|
||||||
hovered.appendSliceAssumeCapacity(selected_substack);
|
hovered.appendSliceAssumeCapacity(selected_substack);
|
||||||
selected.shrinkRetainingCapacity(selected.items.len - selected_substack.len);
|
selected.shrinkRetainingCapacity(selected.items.len - selected_substack.len);
|
||||||
hovered_card = indexOfTopOfStack(hovered_deck.?.items);
|
hovered_card = indexOfTopOfStack(hovered_deck.?.items);
|
||||||
try history.append(gpa, snapshot);
|
cards_moved = true;
|
||||||
break :move_from_selected_to_hovered;
|
break :move_from_selected_to_hovered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +517,7 @@ pub fn doSelectOrPlace(pressed: bool) !void {
|
||||||
foundation.ensureUnusedCapacity(gpa, 1) catch continue;
|
foundation.ensureUnusedCapacity(gpa, 1) catch continue;
|
||||||
foundation.appendAssumeCapacity(selected_deck.?.pop());
|
foundation.appendAssumeCapacity(selected_deck.?.pop());
|
||||||
hovered_card = indexOfTopOfStack(hovered_deck.?.items);
|
hovered_card = indexOfTopOfStack(hovered_deck.?.items);
|
||||||
try history.append(gpa, snapshot);
|
cards_moved = true;
|
||||||
break :move_from_selected_to_hovered;
|
break :move_from_selected_to_hovered;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,6 +537,9 @@ pub fn doSelectOrPlace(pressed: bool) !void {
|
||||||
hovered_card = indexOfTopOfStack(hovered_deck.?.items);
|
hovered_card = indexOfTopOfStack(hovered_deck.?.items);
|
||||||
try history.append(gpa, snapshot);
|
try history.append(gpa, snapshot);
|
||||||
}
|
}
|
||||||
|
if (cards_moved) {
|
||||||
|
try history.append(gpa, snapshot);
|
||||||
|
}
|
||||||
selected_deck = null;
|
selected_deck = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue