@@ -9,7 +9,7 @@ import { camelize, capitalize, hyphenate } from '@vue/shared';
9
9
import { posix as path } from 'path-browserify' ;
10
10
import { getUserPreferences } from 'volar-service-typescript/lib/configs/getUserPreferences' ;
11
11
import { URI } from 'vscode-uri' ;
12
- import { TagNameCasing } from '../nameCasing' ;
12
+ import { checkCasing , TagNameCasing } from '../nameCasing' ;
13
13
import { createAddComponentToOptionEdit , getLastImportNode } from '../plugins/vue-extract-file' ;
14
14
15
15
export function create (
@@ -25,7 +25,6 @@ export function create(
25
25
} ,
26
26
create ( context ) {
27
27
const tsPluginClient = getTsPluginClient ?.( context ) ;
28
- let casing = TagNameCasing . Pascal as TagNameCasing ; // TODO
29
28
30
29
return {
31
30
async provideDocumentDropEdits ( document , _position , dataTransfer ) {
@@ -61,9 +60,9 @@ export function create(
61
60
return ;
62
61
}
63
62
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 ( '.' ) ) ) ) ;
67
66
68
67
const additionalEdit : WorkspaceEdit = { } ;
69
68
const code = [ ...forEachEmbeddedCode ( root ) ] . find ( code =>
@@ -134,7 +133,7 @@ export function create(
134
133
}
135
134
136
135
return {
137
- insertText : `<${ casing === TagNameCasing . Kebab ? hyphenate ( newName ) : newName } $0 />` ,
136
+ insertText : `<${ casing . tag === TagNameCasing . Kebab ? hyphenate ( newName ) : newName } $0 />` ,
138
137
insertTextFormat : 2 satisfies typeof InsertTextFormat . Snippet ,
139
138
additionalEdit,
140
139
} ;
0 commit comments