use character-base ranges when looking for classes

master
Brad Cornes 2021-08-13 17:59:14 +01:00
parent 3d6e9b7e4d
commit 79a3f2b5a1
2 changed files with 5 additions and 4 deletions

View File

@ -306,7 +306,7 @@ function provideClassAttributeCompletions(
context?: CompletionContext context?: CompletionContext
): CompletionList { ): CompletionList {
let str = document.getText({ let str = document.getText({
start: { line: Math.max(position.line - 10, 0), character: 0 }, start: document.positionAt(Math.max(0, document.offsetAt(position) - 500)),
end: position, end: position,
}) })

View File

@ -360,9 +360,10 @@ export async function findClassNameAtPosition(
position: Position position: Position
): Promise<DocumentClassName> { ): Promise<DocumentClassName> {
let classNames = [] let classNames = []
const searchRange = { const positionOffset = doc.offsetAt(position)
start: { line: Math.max(position.line - 10, 0), character: 0 }, const searchRange: Range = {
end: { line: position.line + 10, character: 0 }, start: doc.positionAt(Math.max(0, positionOffset - 500)),
end: doc.positionAt(positionOffset + 500),
} }
if (isCssContext(state, doc, position)) { if (isCssContext(state, doc, position)) {