Skip to content

Fix initialization when path has parentheses #1009

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 4 commits into from
Jul 2, 2024
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
2 changes: 1 addition & 1 deletion packages/tailwindcss-language-server/src/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ export class TW {
console.debug('[GLOBAL] Checking selectors', documentSelector)

for (let selector of documentSelector) {
let pattern = selector.pattern.replace(/[\[\]{}]/g, (m) => `\\${m}`)
let pattern = selector.pattern.replace(/[\[\]{}()]/g, (m) => `\\${m}`)

if (pattern.startsWith('!')) {
if (picomatch(pattern.slice(1), { dot: true })(fsPath)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { test } from 'vitest'
import * as path from 'node:path'
import { withFixture, withWorkspace } from '../common'
import { DidChangeWorkspaceFoldersNotification, HoverRequest } from 'vscode-languageserver'

withFixture('document-selection/basic', (c) => {
test('basic: should provide hovers', async ({ expect }) => {
let textDocument = await c.openDocument({
text: '<div class="bg-[#000]">',
})

let res = await c.sendRequest(HoverRequest.type, {
textDocument,
position: { line: 0, character: 13 },
})

expect(res).toEqual({
contents: {
language: 'css',
value:
'.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}',
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})
})
})

withFixture('document-selection/(parens)', (c) => {
test('parens: should provide hovers', async ({ expect }) => {
let textDocument = await c.openDocument({
text: '<div class="bg-[#000]">',
})

let res = await c.sendRequest(HoverRequest.type, {
textDocument,
position: { line: 0, character: 13 },
})

expect(res).toEqual({
contents: {
language: 'css',
value:
'.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}',
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})
})
})

withFixture('document-selection/[brackets]', (c) => {
test('brackets: should provide hovers', async ({ expect }) => {
let textDocument = await c.openDocument({
text: '<div class="bg-[#000]">',
})

let res = await c.sendRequest(HoverRequest.type, {
textDocument,
position: { line: 0, character: 13 },
})

expect(res).toEqual({
contents: {
language: 'css',
value:
'.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}',
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})
})
})

withFixture('document-selection/{curlies}', (c) => {
test('curlies: should provide hovers', async ({ expect }) => {
let textDocument = await c.openDocument({
text: '<div class="bg-[#000]">',
})

let res = await c.sendRequest(HoverRequest.type, {
textDocument,
position: { line: 0, character: 13 },
})

expect(res).toEqual({
contents: {
language: 'css',
value:
'.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}',
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="bg-[#f00]">test</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="bg-[#0f0]">test</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="bg-[#000]">test</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="bg-[#00f]">test</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
//
}
1 change: 1 addition & 0 deletions packages/vscode-tailwindcss/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix detection of v3 insiders builds ([#1007](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1007))
- Make sure language-specific settings are passed to our language server ([#1006](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1006))
- Fix initialization when path contains parentheses ([#1009](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1009))

## 0.12.3

Expand Down