mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 01:18:21 +00:00
Sort fuzzy_matcher results based on score (#1183)
Co-authored-by: Stephan D <776816+extrawurst@users.noreply.github.com>
This commit is contained in:
parent
5f466ff983
commit
638d7c2648
2 changed files with 8 additions and 4 deletions
|
|
@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* tabs indentation in blame [[@fersilva16](https://github.com/fersilva16)] ([#1111](https://github.com/extrawurst/gitui/issues/1117))
|
||||
* switch focus to index after staging last file ([#1169](https://github.com/extrawurst/gitui/pull/1169))
|
||||
* fix stashlist multi marking not updated after dropping ([#1207](https://github.com/extrawurst/gitui/pull/1207))
|
||||
* exact matches have a higher priority and are placed to the top of the list when fuzzily finding files ([#1183](https://github.com/extrawurst/gitui/pull/1183))
|
||||
|
||||
## [0.20.1] - 2021-01-26
|
||||
|
||||
|
|
|
|||
|
|
@ -88,15 +88,18 @@ impl FileFindPopup {
|
|||
let matcher =
|
||||
fuzzy_matcher::skim::SkimMatcherV2::default();
|
||||
|
||||
self.files_filtered.extend(
|
||||
let mut files =
|
||||
self.files.iter().enumerate().filter_map(|a| {
|
||||
a.1.path.to_str().and_then(|path| {
|
||||
matcher
|
||||
.fuzzy_indices(path, q)
|
||||
.map(|(_, indicies)| (a.0, indicies))
|
||||
.map(|(score, indices)| (score, a.0, indices))
|
||||
})
|
||||
}),
|
||||
);
|
||||
}).collect::<Vec<(_, _, _)>>();
|
||||
|
||||
files.sort_by(|(score1, _, _), (score2, _, _)| score2.cmp(score1));
|
||||
|
||||
self.files_filtered.extend(files.into_iter().map(|entry| (entry.1, entry.2)));
|
||||
}
|
||||
|
||||
self.selection = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue