File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed
packages/tailwindcss-language-service/src/util Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 1
- import { getDefaultTailwindSettings , type DocumentClassList } from './state'
1
+ import { createState , getDefaultTailwindSettings , type DocumentClassList } from './state'
2
2
import { test } from 'vitest'
3
3
import { TextDocument } from 'vscode-languageserver-textdocument'
4
4
import { findClassListsInHtmlRange } from './find'
@@ -13,7 +13,7 @@ test('test astro', async ({ expect }) => {
13
13
14
14
let doc = TextDocument . create ( 'file://file.astro' , 'astro' , 1 , content )
15
15
let defaultSettings = getDefaultTailwindSettings ( )
16
- let state : Parameters < typeof findClassListsInHtmlRange > [ 0 ] = {
16
+ let state = createState ( {
17
17
editor : {
18
18
getConfiguration : async ( ) => ( {
19
19
...defaultSettings ,
@@ -30,7 +30,7 @@ test('test astro', async ({ expect }) => {
30
30
} ,
31
31
} ) ,
32
32
} ,
33
- }
33
+ } )
34
34
35
35
let classLists = await findClassListsInHtmlRange ( state , doc , 'html' )
36
36
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ export type ClassNameMeta = {
173
173
context : string [ ]
174
174
}
175
175
176
- export function getDefaultTailwindSettings ( ) {
176
+ export function getDefaultTailwindSettings ( ) : Settings {
177
177
return {
178
178
editor : { tabSize : 2 } ,
179
179
tailwindCSS : {
@@ -205,6 +205,34 @@ export function getDefaultTailwindSettings() {
205
205
configFile : null ,
206
206
} ,
207
207
} ,
208
- // Return this as const object that satisfies Settings to be able to see the exact default values we specify
209
- } as const satisfies Settings
208
+ }
209
+ }
210
+
211
+ export function createState (
212
+ partial : Omit < Partial < State > , 'editor' > & {
213
+ editor ?: Partial < EditorState >
214
+ } ,
215
+ ) : State {
216
+ return {
217
+ enabled : true ,
218
+ ...partial ,
219
+ editor : {
220
+ get connection ( ) : Connection {
221
+ throw new Error ( 'Not implemented' )
222
+ } ,
223
+ folder : '/' ,
224
+ userLanguages : { } ,
225
+ capabilities : {
226
+ configuration : true ,
227
+ diagnosticRelatedInformation : true ,
228
+ itemDefaults : [ ] ,
229
+ } ,
230
+ getConfiguration : ( ) => {
231
+ throw new Error ( 'Not implemented' )
232
+ } ,
233
+ getDocumentSymbols : async ( ) => [ ] ,
234
+ readDirectory : async ( ) => [ ] ,
235
+ ...partial . editor ,
236
+ } ,
237
+ }
210
238
}
You can’t perform that action at this time.
0 commit comments