Skip to content

Commit

Permalink
Ignore comments when matching class attributes (#1202)
Browse files Browse the repository at this point in the history
Fixes #1200
  • Loading branch information
thecrypticace authored Feb 13, 2025
1 parent 0aa935b commit 1417211
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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'

This comment has been minimized.

Copy link
@smhmd

smhmd Feb 13, 2025

Looks like isVueDoc is unused.

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

0 comments on commit 1417211

Please sign in to comment.