mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Tweak the search limits a bit
This commit is contained in:
parent
1598740292
commit
46514448b7
2 changed files with 6 additions and 3 deletions
|
@ -13,11 +13,13 @@ use crate::{
|
||||||
|
|
||||||
use super::Completions;
|
use super::Completions;
|
||||||
|
|
||||||
|
// TODO kb reuse auto_import assist approach to add trait completion
|
||||||
// TODO kb add a setting toggle for this feature?
|
// TODO kb add a setting toggle for this feature?
|
||||||
pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
|
pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
|
||||||
if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
|
if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
let _p = profile::span("complete_magic");
|
||||||
let current_module = ctx.scope.module()?;
|
let current_module = ctx.scope.module()?;
|
||||||
let anchor = ctx.name_ref_syntax.as_ref()?;
|
let anchor = ctx.name_ref_syntax.as_ref()?;
|
||||||
let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?;
|
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 potential_import_name = ctx.token.to_string();
|
||||||
|
|
||||||
let possible_imports =
|
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| {
|
.filter_map(|import_candidate| {
|
||||||
Some(match import_candidate {
|
Some(match import_candidate {
|
||||||
Either::Left(module_def) => (
|
Either::Left(module_def) => (
|
||||||
|
|
|
@ -35,6 +35,7 @@ pub fn find_similar_imports<'a>(
|
||||||
sema: &Semantics<'a, RootDatabase>,
|
sema: &Semantics<'a, RootDatabase>,
|
||||||
krate: Crate,
|
krate: Crate,
|
||||||
name_to_import: &str,
|
name_to_import: &str,
|
||||||
|
limit: usize,
|
||||||
) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
|
) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
|
||||||
let _p = profile::span("find_similar_imports");
|
let _p = profile::span("find_similar_imports");
|
||||||
find_imports(
|
find_imports(
|
||||||
|
@ -42,10 +43,10 @@ pub fn find_similar_imports<'a>(
|
||||||
krate,
|
krate,
|
||||||
{
|
{
|
||||||
let mut local_query = LocalImportablesQuery::new(name_to_import.to_string());
|
let mut local_query = LocalImportablesQuery::new(name_to_import.to_string());
|
||||||
local_query.limit(40);
|
local_query.limit(limit);
|
||||||
local_query
|
local_query
|
||||||
},
|
},
|
||||||
ExternalImportablesQuery::new(name_to_import).limit(40),
|
ExternalImportablesQuery::new(name_to_import).limit(limit),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue