Skip to content

Commit

Permalink
Improve search list: sorted and longer
Browse files Browse the repository at this point in the history
  • Loading branch information
slai11 committed May 4, 2024
1 parent e46a4fb commit 60d6714
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::{anyhow, Result};
use itertools::Itertools;
use std::process;

use inquire::Select;
Expand Down Expand Up @@ -48,11 +49,17 @@ fn run() -> Result<()> {

Some(("search", _)) => {
let jumpsites = match db::read_db() {
Ok(hash) => hash.values().map(|g| g.path.clone()).collect(),
Ok(hash) => hash
.values()
.sorted_by(|a, b| Ord::cmp(&b.count, &a.count))
.map(|g| g.path.clone())
.collect(),
Err(_) => vec![],
};

let site = Select::new("Jump to:", jumpsites).prompt()?;
let site = Select::new("Jump to:", jumpsites)
.with_page_size(20)
.prompt()?;

switch::switch_to(&site, true)
}
Expand Down

0 comments on commit 60d6714

Please sign in to comment.