fix(lsp): complete exports for import mapped jsr specifiers (#24054)

This commit is contained in:
Nayeem Rahman 2024-06-03 21:32:28 +01:00 committed by GitHub
parent 13924fdb1b
commit 72088f2f52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 557 additions and 477 deletions

File diff suppressed because it is too large Load diff

View file

@ -2105,6 +2105,7 @@ impl Inner {
&self.jsr_search_api, &self.jsr_search_api,
&self.npm_search_api, &self.npm_search_api,
&self.documents, &self.documents,
self.resolver.as_ref(),
self.config.tree.root_import_map().map(|i| i.as_ref()), self.config.tree.root_import_map().map(|i| i.as_ref()),
) )
.await; .await;

View file

@ -1224,6 +1224,7 @@ fn lsp_import_map_import_completions() {
r#"{ r#"{
"imports": { "imports": {
"/~/": "./lib/", "/~/": "./lib/",
"/#/": "./src/",
"fs": "https://example.com/fs/index.js", "fs": "https://example.com/fs/index.js",
"std/": "https://example.com/std@0.123.0/" "std/": "https://example.com/std@0.123.0/"
} }
@ -1296,7 +1297,14 @@ fn lsp_import_map_import_completions() {
"sortText": "/~", "sortText": "/~",
"insertText": "/~", "insertText": "/~",
"commitCharacters": ["\"", "'"], "commitCharacters": ["\"", "'"],
} }, {
"label": "/#",
"kind": 19,
"detail": "(import map)",
"sortText": "/#",
"insertText": "/#",
"commitCharacters": ["\"", "'"],
},
] ]
}) })
); );
@ -1335,8 +1343,8 @@ fn lsp_import_map_import_completions() {
"items": [ "items": [
{ {
"label": "b.ts", "label": "b.ts",
"kind": 9, "kind": 17,
"detail": "(import map)", "detail": "(local)",
"sortText": "1", "sortText": "1",
"filterText": "/~/b.ts", "filterText": "/~/b.ts",
"textEdit": { "textEdit": {
@ -7938,7 +7946,6 @@ fn lsp_completions_snippet() {
(5, 13), (5, 13),
json!({ "triggerKind": 1 }), json!({ "triggerKind": 1 }),
); );
assert!(!list.is_incomplete);
assert_eq!( assert_eq!(
json!(list), json!(list),
json!({ json!({