Skip to content

Commit

Permalink
fix: completion documentations for binding attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Aug 8, 2024
1 parent dc6f943 commit 8c83ee6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/language-service/lib/plugins/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export function loadTemplateData(lang: string) {

for (const attr of [...data.globalAttributes ?? []]) {
if (!attr.name.startsWith('v-')) {
data.globalAttributes?.push({ ...attr, name: `:${attr.name}` });
data.globalAttributes?.push(
{ ...attr, name: `:${attr.name}` },
{ ...attr, name: `v-bind:${attr.name}` }
);
}
}

Expand Down
8 changes: 7 additions & 1 deletion packages/language-service/lib/plugins/vue-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ export function create(
}
}

const originals = new Map<string, html.CompletionItem>();

for (const item of completionList.items) {

if (specialTags.has(item.label)) {
Expand All @@ -755,7 +757,11 @@ export function create(
const itemId = itemIdKey ? readInternalItemId(itemIdKey) : undefined;

if (itemId) {
item.documentation = undefined;
const originalItem = originals.get(itemId.args[1]);
item.documentation = originalItem?.documentation;
}
else if (!originals.has(item.label)) {
originals.set(item.label, item);
}

if (item.kind === 10 satisfies typeof vscode.CompletionItemKind.Property && lastCompletionComponentNames.has(hyphenateTag(item.label))) {
Expand Down

0 comments on commit 8c83ee6

Please sign in to comment.