Sort device paths for select (#8896) (#8897)

automerge
This commit is contained in:
mergify[bot]
2020-03-16 19:43:11 -07:00
committed by GitHub
parent 0102ee3fa9
commit 5a7707362c

View File

@ -432,13 +432,16 @@ pub fn get_ledger_from_info(
return Err(device.error.clone().unwrap()); return Err(device.error.clone().unwrap());
} }
} }
let (pubkeys, device_paths): (Vec<Pubkey>, Vec<String>) = matches let mut matches: Vec<(Pubkey, String)> = matches
.filter(|&device_info| device_info.error.is_none()) .filter(|&device_info| device_info.error.is_none())
.map(|device_info| (device_info.pubkey, device_info.get_pretty_path())) .map(|device_info| (device_info.pubkey, device_info.get_pretty_path()))
.unzip(); .collect();
if pubkeys.is_empty() { if matches.is_empty() {
return Err(RemoteWalletError::NoDeviceFound); return Err(RemoteWalletError::NoDeviceFound);
} }
matches.sort_by(|a, b| a.1.cmp(&b.1));
let (pubkeys, device_paths): (Vec<Pubkey>, Vec<String>) = matches.into_iter().unzip();
let wallet_base_pubkey = if pubkeys.len() > 1 { let wallet_base_pubkey = if pubkeys.len() > 1 {
let selection = Select::with_theme(&ColorfulTheme::default()) let selection = Select::with_theme(&ColorfulTheme::default())
.with_prompt(&format!( .with_prompt(&format!(