|
|
@ -12,7 +12,10 @@ use tui::{
|
|
|
|
use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
|
|
|
|
use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
|
|
|
|
use tui::widgets::Widget;
|
|
|
|
use tui::widgets::Widget;
|
|
|
|
|
|
|
|
|
|
|
|
use std::{cmp::Ordering, time::Instant};
|
|
|
|
use std::{
|
|
|
|
|
|
|
|
cmp::{self, Ordering},
|
|
|
|
|
|
|
|
time::Instant,
|
|
|
|
|
|
|
|
};
|
|
|
|
use std::{collections::HashMap, io::Read, path::PathBuf};
|
|
|
|
use std::{collections::HashMap, io::Read, path::PathBuf};
|
|
|
|
|
|
|
|
|
|
|
|
use crate::ui::{Prompt, PromptEvent};
|
|
|
|
use crate::ui::{Prompt, PromptEvent};
|
|
|
@ -344,11 +347,17 @@ impl<T: Item + 'static> Component for FilePicker<T> {
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, Debug)]
|
|
|
|
#[derive(PartialEq, Eq, Debug)]
|
|
|
|
struct PickerMatch {
|
|
|
|
struct PickerMatch {
|
|
|
|
index: usize,
|
|
|
|
|
|
|
|
score: i64,
|
|
|
|
score: i64,
|
|
|
|
|
|
|
|
index: usize,
|
|
|
|
len: usize,
|
|
|
|
len: usize,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl PickerMatch {
|
|
|
|
|
|
|
|
fn key(&self) -> impl Ord {
|
|
|
|
|
|
|
|
(cmp::Reverse(self.score), self.len, self.index)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl PartialOrd for PickerMatch {
|
|
|
|
impl PartialOrd for PickerMatch {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
Some(self.cmp(other))
|
|
|
|
Some(self.cmp(other))
|
|
|
@ -357,10 +366,7 @@ impl PartialOrd for PickerMatch {
|
|
|
|
|
|
|
|
|
|
|
|
impl Ord for PickerMatch {
|
|
|
|
impl Ord for PickerMatch {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
self.score
|
|
|
|
self.key().cmp(&other.key())
|
|
|
|
.cmp(&other.score)
|
|
|
|
|
|
|
|
.reverse()
|
|
|
|
|
|
|
|
.then_with(|| self.len.cmp(&other.len))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -502,6 +508,7 @@ impl<T: Item> Picker<T> {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
self.matches.sort_unstable();
|
|
|
|
self.matches.sort_unstable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|