Skip to content

Commit

Permalink
feat: improve slots auto-complete
Browse files Browse the repository at this point in the history
close #1251
  • Loading branch information
johnsoncodehk committed Jun 2, 2022
1 parent f644e22 commit 937d41b
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion packages/vue-code-gen/src/generators/template.ts
Expand Up @@ -1322,7 +1322,10 @@ export function generate(
argRange,
{
vueTag: 'template',
capabilities: capabilitiesSet.slotName,
capabilities: {
...capabilitiesSet.slotName,
completion: !!prop.arg,
},
},
false,
);
Expand Down Expand Up @@ -1355,6 +1358,31 @@ export function generate(
},
});
tsCodeGen.addText(`;\n`);

if (isStatic && !prop.arg) {

let offset = prop.loc.start.offset;

if (prop.loc.source.startsWith('#'))
offset += '#'.length;
else if (prop.loc.source.startsWith('v-slot:'))
offset += 'v-slot:'.length;

tsCodeGen.addText(varSlots);
tsCodeGen.addText(`['`);
writeCode(
'',
{ start: offset, end: offset },
SourceMaps.Mode.Offset,
{
vueTag: 'template',
capabilities: {
completion: true,
},
},
);
tsCodeGen.addText(`'];\n`);
}
}
}
}
Expand Down

0 comments on commit 937d41b

Please sign in to comment.