Skip to content

Commit 79a3f2b

Browse files
committed
use character-base ranges when looking for classes
1 parent 3d6e9b7 commit 79a3f2b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/tailwindcss-language-service/src/completionProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function provideClassAttributeCompletions(
306306
context?: CompletionContext
307307
): CompletionList {
308308
let str = document.getText({
309-
start: { line: Math.max(position.line - 10, 0), character: 0 },
309+
start: document.positionAt(Math.max(0, document.offsetAt(position) - 500)),
310310
end: position,
311311
})
312312

packages/tailwindcss-language-service/src/util/find.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,10 @@ export async function findClassNameAtPosition(
360360
position: Position
361361
): Promise<DocumentClassName> {
362362
let classNames = []
363-
const searchRange = {
364-
start: { line: Math.max(position.line - 10, 0), character: 0 },
365-
end: { line: position.line + 10, character: 0 },
363+
const positionOffset = doc.offsetAt(position)
364+
const searchRange: Range = {
365+
start: doc.positionAt(Math.max(0, positionOffset - 500)),
366+
end: doc.positionAt(positionOffset + 500),
366367
}
367368

368369
if (isCssContext(state, doc, position)) {

0 commit comments

Comments
 (0)