Skip to content
Closed
Prev Previous commit
Next Next commit
add feature: twin decorator
  • Loading branch information
lightyen committed Aug 30, 2020
commit 50e6d80f97c12a19e4277a00fc968200dd6d0e47
15 changes: 8 additions & 7 deletions src/lsp/providers/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ function provideClassAttributeCompletions(
start: { line: Math.max(position.line - 10, 0), character: 0 },
end: position,
})

const match = findLast( /(?:\b|:)class(?:Name)?=['"`{]|\btw=['"{]|\btw(?:\.\w+)?`/g, str)

const match = findLast(/(?:\b|:)class(?:Name)?=['"`{]|\btw=['"{]|\btw(?:(?:\(\w+\))|(?:\.\w+))?`/g, str)
if (match === null) {
return null
}

const lexer =
match[0][0] === ':'
? getComputedClassAttributeLexer()
: getClassAttributeLexer()
match[0][0] === ':'
? getComputedClassAttributeLexer()
: getClassAttributeLexer()
lexer.reset(str.substr(match.index + match[0].length - 1))

try {
Expand All @@ -154,6 +154,7 @@ function provideClassAttributeCompletions(
break
}
}
console.log("classList:", classList)

return completionsFromClassList(state, classList, {
start: {
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/util/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function findClassListsInHtmlRange(
range?: Range
): DocumentClassList[] {
const text = doc.getText(range)
const matches = findAll(/(?:\b|:)class(?:Name)?=['"`{]|\btw=['"{]|\btw(?:\.\w+)?`/g, text)
const matches = findAll(/(?:\b|:)class(?:Name)?=['"`{]|\btw=['"{]|\btw(?:(?:\(\w+\))|(?:\.\w+))?`/g, text)
const result: DocumentClassList[] = []

matches.forEach((match) => {
Expand Down