Skip to content

Commit

Permalink
fix(language-service): completion documentations for binding attribut…
Browse files Browse the repository at this point in the history
…es (#4667)
  • Loading branch information
KazariEX authored Aug 9, 2024
1 parent a242050 commit 98b7759
Show file tree
Hide file tree
Showing 2 changed files with 18 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
15 changes: 14 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,18 @@ export function create(
const itemId = itemIdKey ? readInternalItemId(itemIdKey) : undefined;

if (itemId) {
item.documentation = undefined;
let label = hyphenate(itemId.args[1]);
if (label.startsWith('on-')) {
label = 'on' + label.slice('on-'.length);
}
else if (itemId.type === 'componentEvent') {
label = 'on' + label;
}
const original = originals.get(label);
item.documentation = original?.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 98b7759

Please sign in to comment.