From f33704b2b11b7bc22457a52944759b9f3f8989f5 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 11 Feb 2025 14:24:42 -0500 Subject: [PATCH 1/4] Hide pixel equivalents in media queries when `rootFontSize` is not 16px --- .../src/util/pixelEquivalents.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/tailwindcss-language-service/src/util/pixelEquivalents.ts b/packages/tailwindcss-language-service/src/util/pixelEquivalents.ts index ca5441bc..a45cf1cc 100644 --- a/packages/tailwindcss-language-service/src/util/pixelEquivalents.ts +++ b/packages/tailwindcss-language-service/src/util/pixelEquivalents.ts @@ -66,6 +66,12 @@ function getPixelEquivalentsForMediaQuery(params: string, rootFontSize: number): } export function addPixelEquivalentsToMediaQuery(query: string, rootFontSize: number): string { + // Media queries in browsers are not affected by the font size on the `html` element but the + // initial value of font-size as provided by the browser. This is defaults to 16px universally + // so we'll show them *if* the root font size is 16px otherwise we'd be showing potentially + // incorrect values. + if (rootFontSize !== 16) return query + return query.replace(/(?<=^\s*@media\s*).*?$/, (params) => { let comments = getPixelEquivalentsForMediaQuery(params, rootFontSize) return applyComments(params, comments) From 0b2e549661a4e16a7d720c71347dfab6925658ac Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 11 Feb 2025 14:31:38 -0500 Subject: [PATCH 2/4] Update changelog --- packages/vscode-tailwindcss/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vscode-tailwindcss/CHANGELOG.md b/packages/vscode-tailwindcss/CHANGELOG.md index d3b45fd5..cfd7bf04 100644 --- a/packages/vscode-tailwindcss/CHANGELOG.md +++ b/packages/vscode-tailwindcss/CHANGELOG.md @@ -9,6 +9,7 @@ - Fix parsing of `@custom-variant` shorthand in Tailwind CSS language mode ([#1183](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1183)) - Make sure custom regexes apply in Vue `