Tweak `theme` helper detection (#689)
parent
3beff1474a
commit
b0e4fadc4f
|
@ -614,7 +614,7 @@ function provideCssHelperCompletions(
|
||||||
|
|
||||||
const match = text
|
const match = text
|
||||||
.substr(0, text.length - 1) // don't include that extra character from earlier
|
.substr(0, text.length - 1) // don't include that extra character from earlier
|
||||||
.match(/\b(?<helper>config|theme)\(\s*['"]?(?<path>[^)'"]*)$/)
|
.match(/[\s:;/*(){}](?<helper>config|theme)\(\s*['"]?(?<path>[^)'"]*)$/)
|
||||||
|
|
||||||
if (match === null) {
|
if (match === null) {
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -350,7 +350,10 @@ export function findHelperFunctionsInRange(
|
||||||
range?: Range
|
range?: Range
|
||||||
): DocumentHelperFunction[] {
|
): DocumentHelperFunction[] {
|
||||||
const text = getTextWithoutComments(doc, 'css', range)
|
const text = getTextWithoutComments(doc, 'css', range)
|
||||||
let matches = findAll(/\b(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g, text)
|
let matches = findAll(
|
||||||
|
/(?<prefix>[\s:;/*(){}])(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g,
|
||||||
|
text
|
||||||
|
)
|
||||||
|
|
||||||
return matches.map((match) => {
|
return matches.map((match) => {
|
||||||
let quotesBefore = ''
|
let quotesBefore = ''
|
||||||
|
@ -364,7 +367,11 @@ export function findHelperFunctionsInRange(
|
||||||
}
|
}
|
||||||
path = path.replace(/['"]*\s*$/, '')
|
path = path.replace(/['"]*\s*$/, '')
|
||||||
|
|
||||||
let startIndex = match.index + match.groups.helper.length + match.groups.innerPrefix.length
|
let startIndex =
|
||||||
|
match.index +
|
||||||
|
match.groups.prefix.length +
|
||||||
|
match.groups.helper.length +
|
||||||
|
match.groups.innerPrefix.length
|
||||||
|
|
||||||
return {
|
return {
|
||||||
helper: match.groups.helper === 'theme' ? 'theme' : 'config',
|
helper: match.groups.helper === 'theme' ? 'theme' : 'config',
|
||||||
|
|
Loading…
Reference in New Issue