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
): CompletionList {
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,
})

View File

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