mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-01 22:17:53 -06:00
Keywords: opening another library clears the keyword picked in the Keyword List
A keyword picked in one library stayed picked after another library opened, so Cmd+Shift+K edited a keyword with the same path in the new library without a new pick.
This commit is contained in:
@@ -87,6 +87,8 @@ fn switch_library(app: &mut LightcraftApp, path: &str) -> Result<Value, String>
|
||||
app.ui.reference = None;
|
||||
app.ui.compare = None;
|
||||
app.ui.brief_info = crate::state::BriefInfo::default();
|
||||
// a keyword picked in the Keyword List belongs to the library being left
|
||||
app.ui.keyword_list_selected = None;
|
||||
if app.ui.view == crate::state::ViewMode::Reference {
|
||||
app.ui.view = crate::state::ViewMode::PhotoGrid;
|
||||
}
|
||||
|
||||
@@ -196,6 +196,30 @@ fn cmd_shift_k_without_a_picked_keyword_opens_no_dialog() {
|
||||
assert_eq!(h.app.ui.dialog, None, "the picked keyword is gone");
|
||||
}
|
||||
|
||||
/// A keyword picked in one library is not picked in the next one opened, even when that library
|
||||
/// has a keyword at the same path: ⌘⇧K there opens no dialog.
|
||||
#[test]
|
||||
fn opening_another_library_drops_the_picked_keyword() {
|
||||
let dir = std::env::temp_dir().join(format!("lc-ui-keyword-list-switch-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
let mut session = lightcraft_engine::Session::new().with_fs();
|
||||
session.open_library(dir.join("first"), false).unwrap();
|
||||
let app = LightcraftApp::new(session, Services { png: None, ..Default::default() });
|
||||
let mut h = Headless::new(app, [1400.0, 1000.0], 1.0);
|
||||
ask(&mut h, "ui.set", json!({"view": "photoGrid", "right": "keywords"}));
|
||||
run(&mut h, "keyword.create", json!({"name": "Weddings"}));
|
||||
h.app.ui.keyword_list_selected = Some("Weddings".into());
|
||||
let r = h.app.run("app.openLibrary", json!({"path": dir.join("second").to_string_lossy()}));
|
||||
assert!(r.is_ok(), "{r:?}");
|
||||
h.settle(SETTLE);
|
||||
run(&mut h, "keyword.create", json!({"name": "Weddings"}));
|
||||
ask(&mut h, "ui.key", json!({"key": "K", "cmd": true, "shift": true}));
|
||||
assert_eq!(h.app.ui.keyword_list_selected, None, "nothing is picked in the second library");
|
||||
assert_eq!(h.app.ui.dialog, None, "no dialog opens");
|
||||
drop(h);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// The − button deletes the picked keyword after asking how many photos lose it; Cancel keeps it, and undo
|
||||
/// brings a deleted one back.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user