Skip to content

Commit

Permalink
modify completion algo
Browse files Browse the repository at this point in the history
  • Loading branch information
Feel-ix-343 committed Apr 1, 2024
1 parent b4760c5 commit 421fda7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/completion/link_completer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub trait LinkCompleter<'a>: Completer<'a> {

// TODO: This could be slow
let refnames = completions
.iter()
.par_iter()
.map(|completion| completion.refname())
.collect::<HashSet<_>>();

Expand Down
2 changes: 1 addition & 1 deletion src/completion/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn fuzzy_match<'a, T: Matchable>(
let mut matcher = Matcher::new(nucleo_matcher::Config::DEFAULT);
let matches = pattern::Pattern::parse(
filter_text,
pattern::CaseMatching::Ignore,
pattern::CaseMatching::Smart,
Normalization::Smart,
)
.match_list(items, &mut matcher);
Expand Down
2 changes: 1 addition & 1 deletion src/completion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ fn run_completer<'a, T: Completer<'a>>(

let completions = completions
.into_iter()
.take(50)
.take(10)
.flat_map(|completable| {
completable
.completions(&completer)
Expand Down
10 changes: 7 additions & 3 deletions src/vault/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,13 @@ impl Vault {
let resolved_referenceables = self
.md_files
.values()
.par_bridge()
.into_par_iter()
.flat_map(|file| file.get_referenceables())
.collect_vec();
.collect::<Vec<_>>();

let resolved_referenceables_refnames: HashSet<String> = resolved_referenceables
.iter()
.par_iter()
.flat_map(|resolved| {
resolved.get_refname(self.root_dir()).and_then(|refname| {
vec![
Expand All @@ -255,6 +257,8 @@ impl Vault {
references
.iter()
.unique_by(|(_, reference)| &reference.data().reference_text)
.par_bridge()
.into_par_iter()
.filter(|(_, reference)| {
!resolved_referenceables_refnames
.contains(&reference.data().reference_text)
Expand Down Expand Up @@ -284,7 +288,7 @@ impl Vault {
| Reference::Footnote(..)
| Reference::LinkRef(..) => None,
})
.collect_vec()
.collect::<Vec<_>>()
});

resolved_referenceables
Expand Down

0 comments on commit 421fda7

Please sign in to comment.