@@ -21,7 +21,7 @@ export function create(
2121
2222return {
2323
24- async provideInlayHints ( document ) {
24+ async provideInlayHints ( document , range ) {
2525
2626if ( ! isSupportedDocument ( document ) ) {
2727return ;
@@ -68,15 +68,23 @@ export function create(
6868let current : {
6969unburnedRequiredProps : string [ ] ;
7070labelOffset : number ;
71- insertOffset : number ;
7271} | undefined ;
7372
7473while ( ( token = scanner . scan ( ) ) !== html . TokenType . EOS ) {
7574if ( token === html . TokenType . StartTag ) {
75+
7676const tagName = scanner . getTokenText ( ) ;
77+ const tagOffset = scanner . getTokenOffset ( ) ;
78+
7779if ( intrinsicElementNames . has ( tagName ) ) {
7880continue ;
7981}
82+ if ( tagOffset < document . offsetAt ( range . start ) ) {
83+ continue ;
84+ }
85+ if ( tagOffset > document . offsetAt ( range . end ) ) {
86+ break ;
87+ }
8088
8189const checkTag = tagName . includes ( '.' )
8290? tagName
@@ -88,7 +96,6 @@ export function create(
8896current = {
8997unburnedRequiredProps : [ ...componentProps [ checkTag ] ] ,
9098labelOffset : scanner . getTokenOffset ( ) + scanner . getTokenLength ( ) ,
91- insertOffset : scanner . getTokenOffset ( ) + scanner . getTokenLength ( ) ,
9299} ;
93100}
94101}
@@ -141,8 +148,8 @@ export function create(
141148kind : 2 satisfies typeof vscode . InlayHintKind . Parameter ,
142149textEdits : [ {
143150range : {
144- start : document . positionAt ( current . insertOffset ) ,
145- end : document . positionAt ( current . insertOffset ) ,
151+ start : document . positionAt ( current . labelOffset ) ,
152+ end : document . positionAt ( current . labelOffset ) ,
146153} ,
147154newText : ` :${ casing . attr === AttrNameCasing . Kebab ? hyphenateAttr ( requiredProp ) : requiredProp } =` ,
148155} ] ,
@@ -151,11 +158,6 @@ export function create(
151158current = undefined ;
152159}
153160}
154- if ( token === html . TokenType . AttributeName || token === html . TokenType . AttributeValue ) {
155- if ( current ) {
156- current . insertOffset = scanner . getTokenOffset ( ) + scanner . getTokenLength ( ) ;
157- }
158- }
159161}
160162
161163return result ;
0 commit comments