fix issue with nested vue <template>

master
Brad Cornes 2018-10-21 02:09:28 +01:00
parent 6991b22acf
commit 0d07e7b698
1 changed files with 11 additions and 9 deletions

View File

@ -499,15 +499,7 @@ class TailwindIntellisense {
items: this._items,
languages: ['vue'],
regex: /\bclass=["']([^"']*)$/,
enable: text => {
if (
text.indexOf('<template') !== -1 &&
text.indexOf('</template>') === -1
) {
return true
}
return false
},
enable: isWithinTemplate,
triggerCharacters: ["'", '"', ' ', separator]
.concat([
Object.keys(
@ -788,3 +780,13 @@ function createScreenCompletionItemProvider({
' '
)
}
function isWithinTemplate(text: string) {
let regex = /(<\/?template\b)/g
let match
let d = 0
while ((match = regex.exec(text)) !== null) {
d += match[0] === '</template' ? -1 : 1
}
return d !== 0
}