@@ -12,7 +12,10 @@ use tui::{
12use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
12use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
13use tui::widgets::Widget;
13use tui::widgets::Widget;
16+ cmp::{self, Ordering},
15−use std::{cmp::Ordering, time::Instant};
17+ time::Instant,
16use std::{collections::HashMap, io::Read, path::PathBuf};
19use std::{collections::HashMap, io::Read, path::PathBuf};
18use crate::ui::{Prompt, PromptEvent};
21use crate::ui::{Prompt, PromptEvent};
@@ -344,11 +347,17 @@ impl<T: Item + 'static> Component for FilePicker<T> {
345#[derive(PartialEq, Eq, Debug)]
348#[derive(PartialEq, Eq, Debug)]
346struct PickerMatch {
349struct PickerMatch {
348 score: i64,
350 score: i64,
349 len: usize,
352 len: usize,
356+ fn key(&self) -> impl Ord {
357+ (cmp::Reverse(self.score), self.len, self.index)
352impl PartialOrd for PickerMatch {
361impl PartialOrd for PickerMatch {
353 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
362 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
354 Some(self.cmp(other))
363 Some(self.cmp(other))
@@ -357,10 +366,7 @@ impl PartialOrd for PickerMatch {
358impl Ord for PickerMatch {
367impl Ord for PickerMatch {
359 fn cmp(&self, other: &Self) -> Ordering {
368 fn cmp(&self, other: &Self) -> Ordering {
360− self.score
369+ self.key().cmp(&other.key())
363− .then_with(|| self.len.cmp(&other.len))
@@ -502,6 +508,7 @@ impl<T: Item> Picker<T> {
505 self.matches.sort_unstable();
512 self.matches.sort_unstable();