hide keyword suggestions in non trivial paths

This commit is contained in:
Tom Dohrmann 2021-07-21 12:53:50 +02:00
parent 478d435640
commit 7b20904e8b
3 changed files with 10 additions and 16 deletions

View File

@ -20,6 +20,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
cov_mark::hit!(no_keyword_completion_in_attr_of_expr);
return;
}
if ctx.is_non_trivial_path() {
cov_mark::hit!(no_keyword_completion_in_non_trivial_path);
return;
}
// Suggest .await syntax for types that implement Future trait
if let Some(receiver) = ctx.dot_receiver() {

View File

@ -353,6 +353,10 @@ pub(crate) fn is_trivial_path(&self) -> bool {
matches!(self.path_context, Some(PathCompletionContext { is_trivial_path: true, .. }))
}
pub(crate) fn is_non_trivial_path(&self) -> bool {
matches!(self.path_context, Some(PathCompletionContext { is_trivial_path: false, .. }))
}
pub(crate) fn path_qual(&self) -> Option<&ast::Path> {
self.path_context.as_ref().and_then(|it| it.qualifier.as_ref())
}

View File

@ -101,25 +101,11 @@ fn in_item_list_after_attr() {
#[test]
fn in_qualified_path() {
cov_mark::check!(no_keyword_completion_in_non_trivial_path);
check(
r#"crate::$0"#,
expect![[r##"
kw pub(crate)
kw pub
kw unsafe
kw fn
kw const
kw type
kw impl
kw extern
kw use
kw trait
kw static
kw mod
kw enum
kw struct
kw union
ma makro!() #[macro_export] macro_rules! makro
ma makro!() #[macro_export] macro_rules! makro
md module
"##]],
)