Skip to content

Commit

Permalink
sort by crate name len
Browse files Browse the repository at this point in the history
  • Loading branch information
frederik-uni committed Sep 29, 2024
1 parent 3d715f2 commit 7bcafe6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
38 changes: 24 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargotom"
version = "0.13.0"
version = "0.13.1"
edition = "2021"

[dependencies]
Expand All @@ -9,10 +9,10 @@ tower-lsp = "0.20.0"
git2 = { version = "0.19.0", features = ["vendored-openssl"] }
serde_json = "1"
trie-rs = "0.4.2"
clap = { version = "4.5.16", features = ["derive"] }
clap = { version = "4.5.18", features = ["derive"] }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1.39.3", features = ["rt-multi-thread", "macros"]}
tokio = { version = "1.40.0", features = ["rt-multi-thread", "macros"]}
reqwest = {version = "0.12.7", features = ["json"]}
urlencoding = "2.1.3"
webbrowser = "1.0.1"
webbrowser = "1.0.2"
# tame-index = {version = "0.13.2", features = ["sparse"]}
4 changes: 2 additions & 2 deletions src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,8 @@ impl Backend {
};

let root_dep = self.get_root_dependencies(uri).await.unwrap_or_default();
let result = self.crates.read().await.search(&crate_name.value).await;
let mut result = self.crates.read().await.search(&crate_name.value).await;
result.sort_by(|(name_a, _, _), (name_b, _, _)| name_a.len().cmp(&name_b.len()));
Some(
result
.into_iter()
Expand All @@ -670,7 +671,6 @@ impl Backend {
}),
..Default::default()
})
.rev()
.enumerate()
.map(|(index, mut item)| {
item.sort_text = Some(format!("{:04}", index));
Expand Down

0 comments on commit 7bcafe6

Please sign in to comment.