This commit is contained in:
Aleksey Kladov 2020-02-07 14:55:47 +01:00
parent b831b17b3d
commit 2d95047f7c

View file

@ -11,6 +11,8 @@ mod marks;
mod doc_tests; mod doc_tests;
pub mod ast_transform; pub mod ast_transform;
use std::cmp::Ordering;
use either::Either; use either::Either;
use ra_db::FileRange; use ra_db::FileRange;
use ra_ide_db::RootDatabase; use ra_ide_db::RootDatabase;
@ -85,13 +87,12 @@ pub fn resolved_assists(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssi
Assist::Resolved { assist } => assist, Assist::Resolved { assist } => assist,
Assist::Unresolved { .. } => unreachable!(), Assist::Unresolved { .. } => unreachable!(),
}) })
.collect(); .collect::<Vec<_>>();
sort_assists(&mut a); sort_assists(&mut a);
a a
} }
fn sort_assists(assists: &mut Vec<ResolvedAssist>) { fn sort_assists(assists: &mut [ResolvedAssist]) {
use std::cmp::Ordering;
assists.sort_by(|a, b| match (a.get_first_action().target, b.get_first_action().target) { assists.sort_by(|a, b| match (a.get_first_action().target, b.get_first_action().target) {
(Some(a), Some(b)) => a.len().cmp(&b.len()), (Some(a), Some(b)) => a.len().cmp(&b.len()),
(Some(_), None) => Ordering::Less, (Some(_), None) => Ordering::Less,