From f0e8ec01461519dddcb61f1b91b4455a354e38e6 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 9 May 2024 13:18:13 -0400 Subject: fix(lsp): completions for using decl identifiers (#23748) Closes #23688 --- tests/integration/lsp_tests.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/integration') diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 997e89050..d25443623 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -7081,6 +7081,43 @@ fn lsp_npm_completions_auto_import_and_quick_fix_no_import_map() { client.shutdown(); } +#[test] +fn lsp_completions_using_decl() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": r#"function makeResource() { + return { + [Symbol.dispose]() { + }, + }; +} + +using resource = makeResource(); + +res"# + } + })); + + let list = client.get_completion_list( + "file:///a/file.ts", + (9, 3), + json!({ + "triggerKind": 2, + "triggerCharacter": "." + }), + ); + assert!(list.items.iter().any(|i| i.label == "resource")); + assert!(!list.is_incomplete); + + client.shutdown(); +} + #[test] fn lsp_npm_always_caches() { // npm specifiers should always be cached even when not specified -- cgit v1.2.3