Skip to content

Commit

Permalink
fix: auto import creates wrong identifier when dot in file name
Browse files Browse the repository at this point in the history
close #1335
  • Loading branch information
johnsoncodehk committed May 23, 2022
1 parent 1aabb13 commit 7975af0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vue-language-service/src/plugins/vue-template.ts
Expand Up @@ -204,7 +204,7 @@ export default function useVueTemplateLanguagePlugin<T extends ReturnType<typeof
const templateScriptData = vueDocument.file.getTemplateData();
const components = new Set([
...templateScriptData.components,
...templateScriptData.components.map(hyphenate).filter(name => !isIntrinsicElement(runtimeMode, name)),
...templateScriptData.components.map(hyphenate).filter(name => !isIntrinsicElement(runtimeMode, name)),
]);
const offsetRange = range ? {
start: document.offsetAt(range.start),
Expand Down Expand Up @@ -324,7 +324,7 @@ export default function useVueTemplateLanguagePlugin<T extends ReturnType<typeof

const scriptImport = scriptAst ? getLastImportNode(scriptAst) : undefined;
const scriptSetupImport = scriptSetupAst ? getLastImportNode(scriptSetupAst) : undefined;
const componentName = capitalize(camelize(item.label));
const componentName = capitalize(camelize(item.label.replace(/\./g, '-')));
const textDoc = vueDocument.getDocument();
let insertText = '';
const planAResult = await planAInsertText();
Expand Down Expand Up @@ -548,6 +548,7 @@ export default function useVueTemplateLanguagePlugin<T extends ReturnType<typeof
if (baseName.toLowerCase() === 'index') {
baseName = path.basename(path.dirname(vueDocument.uri));
}
baseName = baseName.replace(/\./g, '-');
const componentName_1 = hyphenate(baseName);
const componentName_2 = capitalize(camelize(baseName));
let i: number | '' = '';
Expand Down

0 comments on commit 7975af0

Please sign in to comment.