Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions crates/engine/src/cmd/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1504,8 +1504,12 @@ pub fn specs() -> Vec<CommandSpec> {
select_by
),
cmd!("library.selectNone", "Deselect All", ["Edit"], Some("Cmd+Shift+A"), "{}", always, |s, _| {
let a = s.selection.active;
s.selection = Selection { ids: a.into_iter().collect(), active: a };
// nothing selected and no active photo: the arrows then start again from the view's ends (F-66C0)
s.end_interaction()?;
s.selection = Selection::default();
s.all_selected = None;
s.active_mask = None;
s.active_spot = None;
ok()
}),
cmd!(
Expand Down Expand Up @@ -1555,15 +1559,17 @@ pub fn specs() -> Vec<CommandSpec> {
"Deselect Unflagged Photos",
["Edit"],
None,
"{}: keeps only the flagged (picked) photos of the selection selected; with none flagged it acts as Deselect All (the active photo stays) → {selected}",
"{}: keeps only the flagged (picked) photos of the selection selected; with none flagged it deselects everything, the active photo included → {selected}",
always,
|s, _| {
let keep: Vec<PhotoId> =
s.selection.ids.iter().copied().filter(|id| s.catalog.photo(*id).is_some_and(|ph| ph.flag == Flag::Pick)).collect();
if keep.is_empty() {
let a = s.selection.active;
s.selection = Selection { ids: a.into_iter().collect(), active: a };
s.end_interaction()?;
s.selection = Selection::default();
s.all_selected = None;
s.active_mask = None;
s.active_spot = None;
return Ok(json!({"selected": s.selection.ids.len()}));
}
let active = s.selection.active.filter(|a| keep.contains(a)).or(keep.first().copied());
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/tests_select_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn deselect_unflagged_with_no_pick_or_no_selection_does_not_panic() {
s.execute("photo.flag", &json!({"ids": [vis[0].0, vis[1].0], "flag": "none"})).unwrap();
s.execute("library.select", &json!({"ids": [vis[0].0, vis[1].0], "active": vis[1].0})).unwrap();
s.execute("library.deselectUnflagged", &json!({})).unwrap();
assert_eq!(s.selection, Selection::single(vis[1]), "acts as Deselect All");
assert_eq!(s.selection, Selection::default(), "with none flagged, nothing stays selected, the active photo included");
s.selection = Selection::default();
assert!(s.execute("library.deselectUnflagged", &json!({})).is_ok());
assert_eq!(s.selection, Selection::default());
Expand Down
2 changes: 1 addition & 1 deletion crates/surface/src/loupedeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub fn map_action(action: &str, preset: &dyn Fn(&str) -> Option<String>) -> Mapp
"MoveToNextPhoto" | "SelectRight" | "MoveRight" => c("library.next"),
"MoveToPreviousPhoto" | "SelectLeft" | "MoveLeft" => c("library.previous"),
"SelectAll" => c("library.selectAll"),
"DeselectOtherPhotos" | "SelectNone" => c("library.selectNone"),
"SelectNone" => c("library.selectNone"),
"ToggleZoomView" => c("view.zoomToggle"),
"ZoomIn" => c("view.zoomIn"),
"ZoomOut" => c("view.zoomOut"),
Expand Down
94 changes: 93 additions & 1 deletion crates/ui-egui/src/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,14 +1233,106 @@ mod tests {
#[test]
fn select_only_active_without_active_photo_does_not_change_selection() {
let mut h = library();
// Deselect All keeps the active photo selected, so clear the whole selection state instead.
// a fresh state with no selection and no active photo (Cmd+D leaves the same one)
h.app.session.selection = Default::default();
assert!(!crate::menus::ui_enabled(&h.app, "library.selectOnlyActive"));
assert!(h.app.run("library.selectOnlyActive", json!({})).is_err());
select_only_active_chord(&mut h);
assert!(h.app.session.selection.ids.is_empty());
}

/// Press the Select None chord (Cmd+D, the secondary binding; see `ALIASES`).
fn select_none_chord(h: &mut crate::headless::Headless) {
let r = h.request("ui.key", json!({"key": "D", "cmd": true}), std::time::Duration::from_secs(20));
assert_eq!(r["ok"], true, "{r}");
}

#[test]
fn select_none_clears_every_selected_photo_and_the_active_photo() {
use lcc_catalog::PhotoId;
let mut h = library();
h.app.session.execute("library.select", &json!({"ids": [1, 2, 3], "active": 2})).unwrap();
select_none_chord(&mut h);
assert!(h.app.session.selection.ids.is_empty(), "no photo stays selected: {:?}", h.app.session.selection.ids);
assert_eq!(h.app.session.active(), None, "no photo is active afterwards");
assert!(!h.app.session.selection.contains(PhotoId(2)));
}

#[test]
fn select_none_with_one_photo_selected_leaves_nothing_selected() {
let mut h = library();
h.app.session.execute("library.select", &json!({"ids": [3]})).unwrap();
select_none_chord(&mut h);
assert!(h.app.session.selection.ids.is_empty(), "{:?}", h.app.session.selection);
assert_eq!(h.app.session.active(), None);
}

#[test]
fn select_none_with_nothing_selected_does_nothing_and_raises_no_error() {
let mut h = library();
h.app.session.selection = Default::default();
select_none_chord(&mut h);
assert!(h.app.session.selection.ids.is_empty());
assert_eq!(h.app.session.active(), None);
}

#[test]
fn select_only_active_still_keeps_only_the_active_photo() {
use lcc_catalog::PhotoId;
let mut h = library();
h.app.session.execute("library.select", &json!({"ids": [1, 2, 3], "active": 2})).unwrap();
select_only_active_chord(&mut h);
assert_eq!(h.app.session.selection.ids, vec![PhotoId(2)]);
assert_eq!(h.app.session.active(), Some(PhotoId(2)));
}

#[test]
fn select_none_stays_cleared_across_settled_frames() {
let mut h = library();
h.app.session.execute("library.select", &json!({"ids": [1, 2], "active": 2})).unwrap();
select_none_chord(&mut h);
// a few frames later the grid and filmstrip still draw nothing selected
for _ in 0..3 {
h.settle(std::time::Duration::from_secs(5));
}
assert!(h.app.session.selection.ids.is_empty(), "{:?}", h.app.session.selection);
assert_eq!(h.app.session.active(), None);
}

#[test]
fn after_select_none_the_down_arrow_takes_the_last_photo_of_the_view() {
let mut h = library();
h.app.session.execute("library.select", &json!({"ids": [1, 2], "active": 2})).unwrap();
select_none_chord(&mut h);
let last = *h.app.session.visible_cloned().last().expect("the view has photos");
let r = h.request("ui.key", json!({"key": "down"}), std::time::Duration::from_secs(20));
assert_eq!(r["ok"], true, "{r}");
assert_eq!(h.app.session.active(), Some(last), "↓ after Cmd+D starts from the last photo (F-66C0)");
assert_eq!(h.app.session.selection.ids, vec![last]);
}

#[test]
fn after_select_none_the_up_arrow_takes_the_first_photo_of_the_view() {
let mut h = library();
// a photo well down the view, so a step up from it (the old behaviour) would not land on the first
let vis = h.app.session.visible_cloned();
let (first, active) = (vis[0], vis[vis.len() - 1]);
h.app.session.execute("library.select", &json!({"ids": [active.0], "active": active.0})).unwrap();
select_none_chord(&mut h);
let r = h.request("ui.key", json!({"key": "up"}), std::time::Duration::from_secs(20));
assert_eq!(r["ok"], true, "{r}");
assert_eq!(h.app.session.active(), Some(first), "↑ after Cmd+D starts from the first photo (F-66C0)");
assert_eq!(h.app.session.selection.ids, vec![first]);
}

#[test]
fn select_none_is_listed_as_cmd_d_in_the_classic_set() {
super::set_active(super::KeymapSet::Classic);
let h = library();
// the Edit menu's "Select None" item shows the key that works: Cmd+D, not the engine's declared Cmd+Shift+A
assert_eq!(super::shortcut_of(&h.app.ui.settings.keymap, "library.selectNone"), Some("Cmd+D"));
}

#[test]
fn library_rating_labels_flags_and_undo() {
use lcc_catalog::{ColorLabel, Flag, PhotoId};
Expand Down
5 changes: 3 additions & 2 deletions crates/ui-egui/src/tests_lrc_menus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,14 @@ fn classic_keys_reach_classic_commands() {
let mut h = headless();
key(&mut h, "E", json!({"cmd": true, "shift": true}));
assert!(h.app.ui.module == ModuleId::Export || h.app.ui.dialog.is_some(), "⇧⌘E opens Export");
// ⌘D: Select None (the photo on screen stays the active one)
// ⌘D: Select None (nothing stays selected, and no photo is active)
let mut h = headless();
let ids: Vec<u64> = h.app.session.visible_cloned().iter().take(3).map(|p| p.0).collect();
h.app.run("library.select", json!({"ids": ids, "active": ids[0]})).unwrap();
assert_eq!(h.app.session.selection.ids.len(), 3);
key(&mut h, "D", json!({"cmd": true}));
assert_eq!(h.app.session.selection.ids.len(), 1, "⌘D selects none but the active photo");
assert!(h.app.session.selection.ids.is_empty(), "⌘D selects none");
assert_eq!(h.app.session.active(), None, "⌘D leaves no active photo");
}

// ---- Library / Edit / View / File items that used to be "Coming soon"
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog/unreleased/2026-11-30-cmd-d-select-none.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Library
- **Select None (⌘D) deselects every photo:** it used to keep the active photo selected, so it did the same as Select Only Active Photo. Now nothing stays selected and no photo is active; Cmd+Shift+D still keeps only the active photo.
- **Deselect Unflagged Photos deselects the active photo too:** with no flagged photo in the selection, nothing stays selected.
- **Loupedeck "Select Only Active Photo" is no longer mapped to Select None:** an imported profile that used it now lists that action as dropped.
3 changes: 3 additions & 0 deletions docs/whats-new/2026-12-01-cmd-d-select-none.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Select None deselects every photo
- Edit ▸ Select None (⌘D) now leaves no photo selected and no photo active; before, it kept the active photo selected (issue #1759).
- Deselect Unflagged Photos also deselects the active photo when it isn't flagged.