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

This commit is contained in:
mahmatias
2026-10-21 14:13:17 -03:00
parent 331e0d2103
commit ca26c4046a
2 changed files with 6 additions and 5 deletions
+1
View File
@@ -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();
+5 -5
View File
@@ -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]