@@ -15,6 +15,8 @@ import { loadModelModifiersData, loadTemplateData } from './data';
1515let builtInData : html . HTMLDataV1 ;
1616let modelData : html . HTMLDataV1 ;
1717
18+ const specialTags = new Set ( [ 'slot' , 'component' , 'template' ] ) ;
19+
1820export function create (
1921 mode : 'html' | 'pug' ,
2022 ts : typeof import ( 'typescript' ) ,
@@ -419,14 +421,8 @@ export function create(
419421
420422 if ( builtInData . tags ) {
421423 for ( const tag of builtInData . tags ) {
422- if ( tag . name === 'slot' ) {
423- continue ;
424- }
425- if ( tag . name === 'component' ) {
426- continue ;
427- }
428- if ( tag . name === 'template' ) {
429- continue ;
424+ if ( specialTags . has ( tag . name ) ) {
425+ tag . name = createInternalItemId ( 'specialTag' , [ tag . name ] ) ;
430426 }
431427 if ( casing . tag === TagNameCasing . Kebab ) {
432428 tag . name = hyphenateTag ( tag . name ) ;
@@ -735,6 +731,26 @@ export function create(
735731
736732 for ( const item of completionList . items ) {
737733
734+ if ( specialTags . has ( item . label ) ) {
735+ completionList . items = completionList . items . filter ( i => i !== item ) ;
736+ }
737+
738+ const nameId = readInternalItemId ( item . label ) ;
739+
740+ if ( nameId ) {
741+ const name = nameId . args [ 0 ] ;
742+ item . label = name ;
743+ if ( item . textEdit ) {
744+ item . textEdit . newText = name ;
745+ } ;
746+ if ( item . insertText ) {
747+ item . insertText = name ;
748+ }
749+ if ( item . sortText ) {
750+ item . sortText = name ;
751+ }
752+ }
753+
738754 const itemIdKey = typeof item . documentation === 'string' ? item . documentation : item . documentation ?. value ;
739755 const itemId = itemIdKey ? readInternalItemId ( itemIdKey ) : undefined ;
740756
@@ -848,15 +864,15 @@ export function create(
848864 }
849865} ;
850866
851- function createInternalItemId ( type : 'componentEvent' | 'componentProp' , args : string [ ] ) {
867+ function createInternalItemId ( type : 'componentEvent' | 'componentProp' | 'specialTag' , args : string [ ] ) {
852868 return '__VLS_::' + type + '::' + args . join ( ',' ) ;
853869}
854870
855871function readInternalItemId ( key : string ) {
856872 if ( key . startsWith ( '__VLS_::' ) ) {
857873 const strs = key . split ( '::' ) ;
858874 return {
859- type : strs [ 1 ] as 'componentEvent' | 'componentProp' ,
875+ type : strs [ 1 ] as 'componentEvent' | 'componentProp' | 'specialTag' ,
860876 args : strs [ 2 ] . split ( ',' ) ,
861877 } ;
862878 }
0 commit comments