From 73a1c62f521881d8b3f2a962cd589f4ab45b5b9f Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Tue, 17 Dec 2024 15:45:10 +0100 Subject: [PATCH] fix undo for digit tile placement --- src/editor.rs | 9 ++++----- src/main.rs | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 754b426..c359b23 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -120,7 +120,6 @@ pub enum ExitState { Dont, ExitAndSave, Save, - ExitNoSave, } impl Editor { @@ -1087,10 +1086,10 @@ impl Editor { Tool::Mirror => self.set_tile(pos, Tile::Mirror(self.tool_mirror)), Tool::Digits(_pos) => { self.active_tool = Tool::Digits(Some(pos)); - if let Some(tile) = self.source_board.get_mut(pos) { - if !matches!(tile, Tile::Open(OpenTile::Digit(_), _)) { - *tile = Tile::Open(OpenTile::Digit(0), Claim::Free); - } + + let tile = self.source_board.get_or_blank(pos); + if !matches!(tile, Tile::Open(OpenTile::Digit(_), _)) { + self.set_tile(pos, Tile::Open(OpenTile::Digit(0), Claim::Free)); } } Tool::Blueprint => { diff --git a/src/main.rs b/src/main.rs index 2d30e18..e0f22b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -97,7 +97,6 @@ impl Game { solution.score = editor.score(); solution.save(); } - ExitState::ExitNoSave => self.open_editor = None, } } else { self.draw(&mut d);