Skip to content

Commit ae2c6d9

Browse files
Fix suggestion of utilities with slashes in them in v4 (#1182)
All utilities implicitly have at least `modifiers: []` in the class list when no modifiers are present. We should only change the completion list when there are actually modifiers to show in case an existing utility with a slash in it (e.g. `w-1/2`) is “close” to what the user has typed. This is the other half to fix #1178 b/c while the completions show up but as soon as you type `/` they disappear which is an awful experience.
1 parent cccab4d commit ae2c6d9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ export function completionsFromClassList(
9191
let beforeSlash = partialClassName.split('/').slice(0, -1).join('/')
9292

9393
let baseClassName = beforeSlash.slice(offset)
94-
modifiers = state.classList.find((cls) => Array.isArray(cls) && cls[0] === baseClassName)?.[1]
95-
?.modifiers
94+
modifiers =
95+
state.classList.find((cls) => Array.isArray(cls) && cls[0] === baseClassName)?.[1]
96+
?.modifiers ?? []
9697

97-
if (modifiers) {
98+
if (modifiers.length > 0) {
9899
return withDefaults(
99100
{
100101
isIncomplete: false,

packages/vscode-tailwindcss/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Add details about theme options when hovering ([#1176](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1176))
99
- Fix parsing of `@custom-variant` shorthand in Tailwind CSS language mode ([#1183](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1183))
1010
- Make sure custom regexes apply in Vue `<script>` blocks ([#1177](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1177))
11+
- Fix suggestion of utilities with slashes in them in v4 ([#1182](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1182))
1112

1213
## 0.14.3
1314

0 commit comments

Comments
 (0)