Skip to content

Commit

Permalink
feat: sort features hover list
Browse files Browse the repository at this point in the history
  • Loading branch information
washanhanzi committed Nov 14, 2024
1 parent b824d10 commit adc04c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- hover on git dependency will show the git reference and commit
- hover on `features` will show available features, hover on a feature name
will show its values
- code action for dependency version

# Config

Expand Down
11 changes: 8 additions & 3 deletions src/controller/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ pub fn hover(
.iter()
.map(|(k, v)| (*k, v.iter().map(|fv| fv.to_string()).collect()))
.collect();
let feature_list = features
.keys()
let mut feature_list = features.keys().collect::<Vec<_>>();
feature_list.sort();
let feature_list = feature_list
.iter()
.map(|key| format!("- {}", key))
.collect::<Vec<_>>()
.join("\n");
Expand All @@ -72,9 +74,12 @@ pub fn hover(
let mut s = String::new();
for (_, v) in feature {
for fv in v {
s.push_str(&format!(" - {}\n", fv));
s.push_str(&format!("- {}\n", fv));
}
}
if s.is_empty() {
return None;
}
Some(Hover {
contents: HoverContents::Scalar(MarkedString::String(s)),
range: Some(node.range),
Expand Down

0 comments on commit adc04c3

Please sign in to comment.