Tweak the search limits a bit

This commit is contained in:
Kirill Bulatov 2020-11-13 22:31:41 +02:00
parent 1598740292
commit 46514448b7
2 changed files with 6 additions and 3 deletions

View file

@ -13,11 +13,13 @@ use crate::{
use super::Completions;
// TODO kb reuse auto_import assist approach to add trait completion
// TODO kb add a setting toggle for this feature?
pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
return None;
}
let _p = profile::span("complete_magic");
let current_module = ctx.scope.module()?;
let anchor = ctx.name_ref_syntax.as_ref()?;
let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?;
@ -25,7 +27,7 @@ pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) ->
let potential_import_name = ctx.token.to_string();
let possible_imports =
imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name)
imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400)
.filter_map(|import_candidate| {
Some(match import_candidate {
Either::Left(module_def) => (

View file

@ -35,6 +35,7 @@ pub fn find_similar_imports<'a>(
sema: &Semantics<'a, RootDatabase>,
krate: Crate,
name_to_import: &str,
limit: usize,
) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
let _p = profile::span("find_similar_imports");
find_imports(
@ -42,10 +43,10 @@ pub fn find_similar_imports<'a>(
krate,
{
let mut local_query = LocalImportablesQuery::new(name_to_import.to_string());
local_query.limit(40);
local_query.limit(limit);
local_query
},
ExternalImportablesQuery::new(name_to_import).limit(40),
ExternalImportablesQuery::new(name_to_import).limit(limit),
)
}