@@ -9,7 +9,7 @@ import { camelize, capitalize, hyphenate } from '@vue/shared';
99import { posix as path } from 'path-browserify' ;
1010import { getUserPreferences } from 'volar-service-typescript/lib/configs/getUserPreferences' ;
1111import { URI } from 'vscode-uri' ;
12- import { TagNameCasing } from '../nameCasing' ;
12+ import { checkCasing , TagNameCasing } from '../nameCasing' ;
1313import { createAddComponentToOptionEdit , getLastImportNode } from '../plugins/vue-extract-file' ;
1414
1515export function create (
@@ -25,7 +25,6 @@ export function create(
2525 } ,
2626 create ( context ) {
2727 const tsPluginClient = getTsPluginClient ?.( context ) ;
28- let casing = TagNameCasing . Pascal as TagNameCasing ; // TODO
2928
3029 return {
3130 async provideDocumentDropEdits ( document , _position , dataTransfer ) {
@@ -61,9 +60,9 @@ export function create(
6160 return ;
6261 }
6362
64- let baseName = importUri . slice ( importUri . lastIndexOf ( '/' ) + 1 ) ;
65- baseName = baseName . slice ( 0 , baseName . lastIndexOf ( '.' ) ) ;
66- const newName = capitalize ( camelize ( baseName ) ) ;
63+ const casing = await checkCasing ( context , decoded ! [ 0 ] ) ;
64+ const baseName = path . basename ( importUri ) ;
65+ const newName = capitalize ( camelize ( baseName . slice ( 0 , baseName . lastIndexOf ( '.' ) ) ) ) ;
6766
6867 const additionalEdit : WorkspaceEdit = { } ;
6968 const code = [ ...forEachEmbeddedCode ( root ) ] . find ( code =>
@@ -134,7 +133,7 @@ export function create(
134133 }
135134
136135 return {
137- insertText : `<${ casing === TagNameCasing . Kebab ? hyphenate ( newName ) : newName } $0 />` ,
136+ insertText : `<${ casing . tag === TagNameCasing . Kebab ? hyphenate ( newName ) : newName } $0 />` ,
138137 insertTextFormat : 2 satisfies typeof InsertTextFormat . Snippet ,
139138 additionalEdit,
140139 } ;
0 commit comments