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