-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix initialization when path has parentheses (#1009)
* Fix initialization when path has parentheses * Add test * Add fixtures * Update changelog
- Loading branch information
1 parent
f4b0e54
commit a094787
Showing
11 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
packages/tailwindcss-language-server/tests/env/document-selection.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } }, | ||
}) | ||
}) | ||
}) |
1 change: 1 addition & 0 deletions
1
packages/tailwindcss-language-server/tests/fixtures/document-selection/(parens)/file.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class="bg-[#f00]">test</div> |
3 changes: 3 additions & 0 deletions
3
...tailwindcss-language-server/tests/fixtures/document-selection/(parens)/tailwind.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
// | ||
} |
1 change: 1 addition & 0 deletions
1
packages/tailwindcss-language-server/tests/fixtures/document-selection/[brackets]/file.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class="bg-[#0f0]">test</div> |
3 changes: 3 additions & 0 deletions
3
...ilwindcss-language-server/tests/fixtures/document-selection/[brackets]/tailwind.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
// | ||
} |
1 change: 1 addition & 0 deletions
1
packages/tailwindcss-language-server/tests/fixtures/document-selection/basic/file.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class="bg-[#000]">test</div> |
3 changes: 3 additions & 0 deletions
3
...es/tailwindcss-language-server/tests/fixtures/document-selection/basic/tailwind.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
// | ||
} |
1 change: 1 addition & 0 deletions
1
packages/tailwindcss-language-server/tests/fixtures/document-selection/{curlies}/file.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class="bg-[#00f]">test</div> |
3 changes: 3 additions & 0 deletions
3
...ailwindcss-language-server/tests/fixtures/document-selection/{curlies}/tailwind.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters