Skip to content

Commit c058f1d

Browse files
author
Brad Cornes
committed
Merge branch 'master' of github.com:bradlc/vscode-tailwindcss
2 parents 6907071 + 0d07e7b commit c058f1d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/extension.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,7 @@ class TailwindIntellisense {
499499
items: this._items,
500500
languages: ['vue'],
501501
regex: /\bclass=["']([^"']*)$/,
502-
enable: text => {
503-
if (
504-
text.indexOf('<template') !== -1 &&
505-
text.indexOf('</template>') === -1
506-
) {
507-
return true
508-
}
509-
return false
510-
},
502+
enable: isWithinTemplate,
511503
triggerCharacters: ["'", '"', ' ', separator]
512504
.concat([
513505
Object.keys(
@@ -788,3 +780,13 @@ function createScreenCompletionItemProvider({
788780
' '
789781
)
790782
}
783+
784+
function isWithinTemplate(text: string) {
785+
let regex = /(<\/?template\b)/g
786+
let match
787+
let d = 0
788+
while ((match = regex.exec(text)) !== null) {
789+
d += match[0] === '</template' ? -1 : 1
790+
}
791+
return d !== 0
792+
}

0 commit comments

Comments
 (0)