Skip to content

Ignore comments when matching class attributes #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
1 change: 1 addition & 0 deletions packages/vscode-tailwindcss/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Prerelease

- Show light color swatch from light-dark() functions ([#1199](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1199))
- Ignore comments when matching class attributes ([#1202](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1202))

## 0.14.4

Expand Down