Skip to content

Commit 8153cf0

Browse files
authored
fix(oma-pm): fix sort candidate on non filter candidate version mode (#335)
1 parent e8bac97 commit 8153cf0

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

oma-pm/src/matches.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,10 @@ impl<'a> PackagesMatcher<'a> {
240240

241241
// 确保数组第一个是 candidate version
242242
if !self.filter_candidate {
243-
let candidate_list = res
244-
.iter()
245-
.enumerate()
246-
.filter_map(|(idx, pkg)| {
247-
if pkg.is_candidate_version(self.cache) {
248-
Some(idx)
249-
} else {
250-
None
251-
}
252-
})
253-
.collect::<Vec<_>>();
254-
255-
for idx in candidate_list {
256-
let pkg = res.remove(idx);
257-
res.insert(0, pkg);
258-
}
243+
res.sort_by(|a, b| {
244+
b.is_candidate_version(self.cache)
245+
.cmp(&a.is_candidate_version(self.cache))
246+
});
259247
}
260248

261249
Ok(res)

0 commit comments

Comments
 (0)