Skip to content

Commit

Permalink
fix: component tag autocomplete not working if not use in template
Browse files Browse the repository at this point in the history
close #1952
  • Loading branch information
johnsoncodehk committed Oct 8, 2022
1 parent 83378f5 commit 1a2757b
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -418,6 +418,7 @@ export default function useVueTemplateLanguagePlugin<T extends ReturnType<typeof
provideTags: () => {

const components = checkComponentNames(context.typescript.module, context.typescript.languageService, vueSourceFile);
const scriptSetupRanges = vueSourceFile.sfc.scriptSetupAst ? vue.parseScriptSetupRanges(context.typescript.module, vueSourceFile.sfc.scriptSetupAst) : undefined;
const names = new Set<string>();
const tags: html.ITagData[] = [];

Expand All @@ -430,6 +431,16 @@ export default function useVueTemplateLanguagePlugin<T extends ReturnType<typeof
}
}

for (const binding of scriptSetupRanges?.bindings ?? []) {
const name = vueSourceFile.sfc.scriptSetup!.content.substring(binding.start, binding.end);
if (tagNameCasing === TagNameCasing.Kebab) {
names.add(hyphenate(name));
}
else if (tagNameCasing === TagNameCasing.Pascal) {
names.add(name);
}
}

for (const name of names) {
tags.push({
name: name,
Expand Down

0 comments on commit 1a2757b

Please sign in to comment.