Skip to content

Commit

Permalink
feat: import completion normalize Index to folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jan 8, 2023
1 parent 821cb28 commit 6168c50
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vue-language-tools/vue-language-service/src/languageService.ts
Expand Up @@ -86,6 +86,16 @@ export function getLanguageServicePlugins(vueCompilerOptions: VueCompilerOptions
) {
let newName = item.textEdit.newText.slice(0, -'Vue'.length);
newName = newName[0].toUpperCase() + newName.substring(1);
if (newName === 'Index') {
const tsItem = (item.data as Data).originalItem;
if (tsItem.source) {
const dirs = tsItem.source.split('/');
if (dirs.length >= 3) {
newName = dirs[dirs.length - 2];
newName = newName[0].toUpperCase() + newName.substring(1);
}
}
}
item.additionalTextEdits[0].newText = item.additionalTextEdits[0].newText.replace(
'import ' + item.textEdit.newText + ' from ',
'import ' + newName + ' from ',
Expand Down

0 comments on commit 6168c50

Please sign in to comment.