aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorrobojumper <[email protected]>2019-02-09 00:57:08 +0000
committerrobojumper <[email protected]>2019-02-09 00:57:08 +0000
commit4fdeb54bb5c7ba0704839a65996766d223c51fc1 (patch)
tree97388dafe71ececcbaf97249021b9c8d49786ccf /crates/ra_assists/src
parenta70589712a06e8dd5d90997d457fc87d3da684dc (diff)
Improve sorting delegate
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/lib.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index ce5ee365e..7928b4983 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -65,13 +65,11 @@ where
65 Assist::Unresolved(..) => unreachable!(), 65 Assist::Unresolved(..) => unreachable!(),
66 }) 66 })
67 .collect::<Vec<(AssistLabel, AssistAction)>>(); 67 .collect::<Vec<(AssistLabel, AssistAction)>>();
68 a.sort_by(|a, b| match a { 68 a.sort_by(|a, b| match (a.1.target, b.1.target) {
69 // Some(y) < Some(x) < None for y < x 69 (Some(a), Some(b)) => a.len().cmp(&b.len()),
70 (_, AssistAction { target: Some(a), .. }) => match b { 70 (Some(_), None) => Ordering::Less,
71 (_, AssistAction { target: Some(b), .. }) => a.len().cmp(&b.len()), 71 (None, Some(_)) => Ordering::Greater,
72 _ => Ordering::Less, 72 (None, None) => Ordering::Equal,
73 },
74 _ => Ordering::Greater,
75 }); 73 });
76 a 74 a
77 }) 75 })