@@ -21,7 +21,7 @@ export function create(
21
21
22
22
return {
23
23
24
- async provideInlayHints ( document ) {
24
+ async provideInlayHints ( document , range ) {
25
25
26
26
if ( ! isSupportedDocument ( document ) ) {
27
27
return ;
@@ -68,15 +68,23 @@ export function create(
68
68
let current : {
69
69
unburnedRequiredProps : string [ ] ;
70
70
labelOffset : number ;
71
- insertOffset : number ;
72
71
} | undefined ;
73
72
74
73
while ( ( token = scanner . scan ( ) ) !== html . TokenType . EOS ) {
75
74
if ( token === html . TokenType . StartTag ) {
75
+
76
76
const tagName = scanner . getTokenText ( ) ;
77
+ const tagOffset = scanner . getTokenOffset ( ) ;
78
+
77
79
if ( intrinsicElementNames . has ( tagName ) ) {
78
80
continue ;
79
81
}
82
+ if ( tagOffset < document . offsetAt ( range . start ) ) {
83
+ continue ;
84
+ }
85
+ if ( tagOffset > document . offsetAt ( range . end ) ) {
86
+ break ;
87
+ }
80
88
81
89
const checkTag = tagName . includes ( '.' )
82
90
? tagName
@@ -88,7 +96,6 @@ export function create(
88
96
current = {
89
97
unburnedRequiredProps : [ ...componentProps [ checkTag ] ] ,
90
98
labelOffset : scanner . getTokenOffset ( ) + scanner . getTokenLength ( ) ,
91
- insertOffset : scanner . getTokenOffset ( ) + scanner . getTokenLength ( ) ,
92
99
} ;
93
100
}
94
101
}
@@ -141,8 +148,8 @@ export function create(
141
148
kind : 2 satisfies typeof vscode . InlayHintKind . Parameter ,
142
149
textEdits : [ {
143
150
range : {
144
- start : document . positionAt ( current . insertOffset ) ,
145
- end : document . positionAt ( current . insertOffset ) ,
151
+ start : document . positionAt ( current . labelOffset ) ,
152
+ end : document . positionAt ( current . labelOffset ) ,
146
153
} ,
147
154
newText : ` :${ casing . attr === AttrNameCasing . Kebab ? hyphenateAttr ( requiredProp ) : requiredProp } =` ,
148
155
} ] ,
@@ -151,11 +158,6 @@ export function create(
151
158
current = undefined ;
152
159
}
153
160
}
154
- if ( token === html . TokenType . AttributeName || token === html . TokenType . AttributeValue ) {
155
- if ( current ) {
156
- current . insertOffset = scanner . getTokenOffset ( ) + scanner . getTokenLength ( ) ;
157
- }
158
- }
159
161
}
160
162
161
163
return result ;
0 commit comments