diff --git a/plugins/rust-explorer/src/main.rs b/plugins/rust-explorer/src/main.rs index 2e128eb8..75e46e4e 100644 --- a/plugins/rust-explorer/src/main.rs +++ b/plugins/rust-explorer/src/main.rs @@ -162,6 +162,7 @@ static SHOW_HIDDEN: AtomicBool = AtomicBool::new(false); // Ctrl+H static NAV: AtomicBool = AtomicBool::new(false); // loading from the back / forward trail: do not record it again const WM_NAV: u32 = WM_APP + 3; // wp: 1 back, 2 forward, 3 properties, 4 up (sent from the message loop for Alt+key) const WM_DIRSIZE: u32 = WM_APP + 7; // folder-size worker -> UI: wp = Box<(era, folder name, bytes)> (#147) +const WM_SELECT: u32 = WM_APP + 8; // wp = Box: the row to select once the window is up (started with /select) const WM_JOB: u32 = WM_APP + 5; // jobs.rs worker finished: wp = Box> (the error, if any) fn row(name: String, m: Option<&fs::Metadata>) -> Row { @@ -2012,7 +2013,8 @@ unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> LRESU if desk() { let _ = sh::register_drop(h as _, h as isize); } let (start, pick) = if desk() { (sh::desktop_dirs().into_iter().next().unwrap_or_default(), None) } else { start_target() }; load(h, start); - if let Some(name) = pick { select_row(&name); } + // the list is still 0x0 here, so scrolling to the row now is lost: select it once the window is shown and sized + if let Some(name) = pick { PostMessageW(h, WM_SELECT, Box::into_raw(Box::new(name)) as usize, 0); } if desk() { use windows::Win32::UI::Shell::{FOLDERID_Desktop, FOLDERID_Documents, FOLDERID_Downloads, FOLDERID_Music, FOLDERID_Pictures, FOLDERID_Videos}; let mut dirs: Vec = [&FOLDERID_Desktop, &FOLDERID_Downloads, &FOLDERID_Documents, &FOLDERID_Pictures, &FOLDERID_Music, &FOLDERID_Videos].iter().filter_map(|id| sh::known_dir(id)).collect(); @@ -2289,6 +2291,7 @@ unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> LRESU } WM_SETFOCUS => { SetFocus(ST.with_borrow(|st| st.list)); 0 } WM_APP => { reload(h); 0 } + WM_SELECT => { select_row(&Box::from_raw(wp as *mut String)); 0 } shellwin::WM_SHELL_SELECT => { shell_select(h as isize, *Box::from_raw(lp as *mut PathBuf)); 0 } WM_JOB => { let err = *Box::from_raw(wp as *mut Option);