@@ -55,12 +55,22 @@ function isIdentifierPart(code: number) {
55
55
* Gets the span of word in a template that surrounds `position`. If there is no word around
56
56
* `position`, nothing is returned.
57
57
*/
58
- function getBoundedWordSpan ( templateInfo : AstResult , position : number ) : ts . TextSpan | undefined {
58
+ function getBoundedWordSpan (
59
+ templateInfo : AstResult , position : number , ast : HtmlAst | undefined ) : ts . TextSpan | undefined {
59
60
const { template} = templateInfo ;
60
61
const templateSrc = template . source ;
61
62
62
63
if ( ! templateSrc ) return ;
63
64
65
+ if ( ast instanceof Element ) {
66
+ // The HTML tag may include `-` (e.g. `app-root`),
67
+ // so use the HtmlAst to get the span before ayazhafiz refactor the code.
68
+ return {
69
+ start : templateInfo . template . span . start + ast . startSourceSpan ! . start . offset + 1 ,
70
+ length : ast . name . length
71
+ } ;
72
+ }
73
+
64
74
// TODO(ayazhafiz): A solution based on word expansion will always be expensive compared to one
65
75
// based on ASTs. Whatever penalty we incur is probably manageable for small-length (i.e. the
66
76
// majority of) identifiers, but the current solution involes a number of branchings and we can't
@@ -185,7 +195,7 @@ export function getTemplateCompletions(
185
195
null ) ;
186
196
}
187
197
188
- const replacementSpan = getBoundedWordSpan ( templateInfo , position ) ;
198
+ const replacementSpan = getBoundedWordSpan ( templateInfo , position , mostSpecific ) ;
189
199
return result . map ( entry => {
190
200
return {
191
201
...entry ,
0 commit comments