Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

fix(guided): a stale selected index does not fire an empty guides edit; docs: un-mojibake the dashes

mahmatiasca26c4046a34
diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs
index fb483f61c..109ff7023 100644
--- a/crates/ui-egui/src/shortcuts.rs
+++ b/crates/ui-egui/src/shortcuts.rs
@@ -564,6 +564,7 @@ pub fn handle(app: &mut LightcraftApp, ctx: &egui::Context) {
if let (Some((photo, i)), Some(active)) = (app.ui.selected_guide, app.session.active()) {
if photo == active.0
&& let Some(d) = app.session.develop_of(active)
+ && i < d.geometry.guides.len()
{
let guides: Vec<[f64; 4]> =
d.geometry.guides.iter().enumerate().filter(|(k, _)| *k != i).map(|(_, (a, b))| [a.x, a.y, b.x, b.y]).collect();
diff --git a/crates/ui-egui/src/tests_guided_guides.rs b/crates/ui-egui/src/tests_guided_guides.rs
index 6d6b8df0d..89fe6fbbe 100644
--- a/crates/ui-egui/src/tests_guided_guides.rs
+++ b/crates/ui-egui/src/tests_guided_guides.rs
@@ -73,7 +73,7 @@ fn delete_removes_the_selected_guide() {
let (a, b) = d.develop.geometry.guides[0];
assert!(
(a.x - 0.2).abs() < 1e-6 && (a.y - 0.3).abs() < 1e-6 && (b.x - 0.8).abs() < 1e-6 && (b.y - 0.3).abs() < 1e-6,
- "the first guide survived: {a:?}–{b:?}"
+ "the first guide survived: {a:?}–{b:?}"
);
}
@@ -128,8 +128,8 @@ fn drawing_a_new_guide_clears_the_selection() {
assert_eq!(h.app.ui.selected_guide, None, "and the click's selection is gone");
}
-/// A press on an endpoint drags it: the guide follows the pointer — the other end and the other
-/// guide untouched — the moved guide ends up selected, and nothing is added (one edit, on release).
+/// A press on an endpoint drags it: the guide follows the pointer — the other end and the other
+/// guide untouched — the moved guide ends up selected, and nothing is added (one edit, on release).
#[test]
fn dragging_a_guide_endpoint_moves_it() {
let mut h = guided();
@@ -178,12 +178,12 @@ fn clicking_an_endpoint_selects_it_without_changing_it() {
let (a, b) = d.develop.geometry.guides[1];
assert!(
(a.x - 0.2).abs() < 1e-6 && (a.y - 0.7).abs() < 1e-6 && (b.x - 0.8).abs() < 1e-6 && (b.y - 0.7).abs() < 1e-6,
- "the guide is untouched: {a:?}–{b:?}"
+ "the guide is untouched: {a:?}–{b:?}"
);
assert_eq!(h.app.session.undo.len(), undo, "a click is not an edit");
}
-/// A new guide starts at the press point itself: a press, one far jump, a release — the guide
+/// A new guide starts at the press point itself: a press, one far jump, a release — the guide
/// spans exactly those two points (it used to start where the drag threshold was crossed, so the
/// anchor was already at the far end).
#[test]