diff --git a/libs/wingc/src/lsp/completions.rs b/libs/wingc/src/lsp/completions.rs index 49dc439a515..f0fee36dbb9 100644 --- a/libs/wingc/src/lsp/completions.rs +++ b/libs/wingc/src/lsp/completions.rs @@ -363,6 +363,18 @@ pub fn on_completion(params: lsp_types::CompletionParams) -> CompletionResponse return filter_completions(completions); } + + if node_to_complete_kind == "type_identifier" { + // we're in an incomplete bare type (e.g. `new clou` or `extends clo`), + // we should attempt to use the text we have to match existing scope symbols + return filter_completions(get_current_scope_completions( + &types, + &scope_visitor, + &node_to_complete, + &preceding_text, + )); + } + return vec![]; } } else if matches!( @@ -1309,6 +1321,21 @@ new cloud. // assert!(new_expression_nested.iter().all(|item| item.detail.as_ref().unwrap().starts_with("preflight"))) ); + test_completion_list!( + new_expression_partial_namespace, + r#" +bring cloud; + +struct cloudy {} + +new clo + //^ +"#, + assert!(!new_expression_partial_namespace.is_empty()) + assert!(new_expression_partial_namespace.len() == 1) + assert!(new_expression_partial_namespace.get(0).unwrap().label == "cloud") + ); + test_completion_list!( static_method_call, r#" diff --git a/libs/wingc/src/lsp/snapshots/completions/new_expression_partial_namespace.snap b/libs/wingc/src/lsp/snapshots/completions/new_expression_partial_namespace.snap new file mode 100644 index 00000000000..bc37b6bf184 --- /dev/null +++ b/libs/wingc/src/lsp/snapshots/completions/new_expression_partial_namespace.snap @@ -0,0 +1,10 @@ +--- +source: libs/wingc/src/lsp/completions.rs +--- +- label: cloud + kind: 9 + documentation: + kind: markdown + value: "Module `cloud`" + sortText: kk|cloud +