Skip to content

Commit

Permalink
Enable lazy computation of import completion items
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Jun 7, 2019
1 parent f77a9c8 commit 3e41fa0
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/completion/latex/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ pub async fn import<'a, F>(
where
F: Fn(Cow<'static, str>) -> CompletionItem,
{
let items = request
.resolver
.files_by_name
.values()
.filter(|file| file.extension().and_then(OsStr::to_str) == Some(extension))
.flat_map(|file| file.file_stem().unwrap().to_str())
.map(|name| factory(Cow::from(name.to_owned())))
.collect();

LatexCombinators::argument(request, &commands, 0, async move |_| items).await
LatexCombinators::argument(request, &commands, 0, async move |_| {
request
.resolver
.files_by_name
.values()
.filter(|file| file.extension().and_then(OsStr::to_str) == Some(extension))
.flat_map(|file| file.file_stem().unwrap().to_str())
.map(|name| factory(Cow::from(name.to_owned())))
.collect()
})
.await
}

#[cfg(test)]
Expand Down

0 comments on commit 3e41fa0

Please sign in to comment.