Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove comments from text when matching class attributes
  • Loading branch information
thecrypticace committed Feb 13, 2025
commit 031219cdeb207767f503a9c741671da7e01fa856
16 changes: 13 additions & 3 deletions packages/tailwindcss-language-service/src/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'
import dlv from 'dlv'
import removeMeta from './util/removeMeta'
import { formatColor, getColor, getColorFromValue } from './util/color'
import { isHtmlContext } from './util/html'
import { isHtmlContext, isHtmlDoc, isVueDoc } from './util/html'
import { isCssContext } from './util/css'
import { findLast, matchClassAttributes } from './util/find'
import { stringifyConfigValue, stringifyCss } from './util/stringify'
Expand Down Expand Up @@ -728,10 +728,20 @@ async function provideClassAttributeCompletions(
position: Position,
context?: CompletionContext,
): Promise<CompletionList> {
let str = document.getText({
let range: Range = {
start: document.positionAt(Math.max(0, document.offsetAt(position) - SEARCH_RANGE)),
end: position,
})
}

let str: string

if (isJsDoc(state, document)) {
str = getTextWithoutComments(document, 'js', range)
} else if (isHtmlDoc(state, document)) {
str = getTextWithoutComments(document, 'html', range)
} else {
str = document.getText(range)
}

let settings = (await state.editor.getConfiguration(document.uri)).tailwindCSS

Expand Down