Skip to content

v4: Improve DX around completions when prefixes are in use #1292

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 3 commits into from
Apr 4, 2025
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
Add test
  • Loading branch information
thecrypticace committed Apr 3, 2025
commit 4669ee4d853591657dca8201dbc6c3c9715c83bc
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,80 @@ defineTest({
},
})

defineTest({
name: 'v4: Completions show after a variant arbitrary value, using prefixes',
fs: {
'app.css': css`
@import 'tailwindcss' prefix(tw);
`,
},
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
handle: async ({ client }) => {
let document = await client.open({
lang: 'html',
text: '<div class="tw:data-[foo]:">',
})

// <div class="tw:data-[foo]:">
// ^
let completion = await document.completions({ line: 0, character: 26 })

expect(completion?.items.length).toBe(19236)
},
})

defineTest({
name: 'v4: Variant and utility suggestions show prefix when one has been typed',
fs: {
'app.css': css`
@import 'tailwindcss' prefix(tw);
`,
},
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
handle: async ({ client }) => {
let document = await client.open({
lang: 'html',
text: '<div class="">',
})

// <div class="">
// ^
let completion = await document.completions({ line: 0, character: 12 })

expect(completion?.items.length).toBe(19237)

// Verify that variants and utilities are all prefixed
let prefixed = completion.items.filter((item) => !item.label.startsWith('tw:'))
expect(prefixed).toHaveLength(0)
},
})

defineTest({
name: 'v4: Variant and utility suggestions hide prefix when it has been typed',
fs: {
'app.css': css`
@import 'tailwindcss' prefix(tw);
`,
},
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
handle: async ({ client }) => {
let document = await client.open({
lang: 'html',
text: '<div class="tw:">',
})

// <div class="tw:">
// ^
let completion = await document.completions({ line: 0, character: 15 })

expect(completion?.items.length).toBe(19236)

// Verify that no variants and utilities have prefixes
let prefixed = completion.items.filter((item) => item.label.startsWith('tw:'))
expect(prefixed).toHaveLength(0)
},
})

defineTest({
name: 'v4: Completions show inside class functions in JS/TS files',
fs: {
Expand Down