Skip to content

Commit e29481d

Browse files
committed
wip
1 parent 94f1300 commit e29481d

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

packages/tailwindcss-language-service/src/util/find.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getDefaultTailwindSettings, type DocumentClassList } from './state'
1+
import { createState, getDefaultTailwindSettings, type DocumentClassList } from './state'
22
import { test } from 'vitest'
33
import { TextDocument } from 'vscode-languageserver-textdocument'
44
import { findClassListsInHtmlRange } from './find'
@@ -13,7 +13,7 @@ test('test astro', async ({ expect }) => {
1313

1414
let doc = TextDocument.create('file://file.astro', 'astro', 1, content)
1515
let defaultSettings = getDefaultTailwindSettings()
16-
let state: Parameters<typeof findClassListsInHtmlRange>[0] = {
16+
let state = createState({
1717
editor: {
1818
getConfiguration: async () => ({
1919
...defaultSettings,
@@ -30,7 +30,7 @@ test('test astro', async ({ expect }) => {
3030
},
3131
}),
3232
},
33-
}
33+
})
3434

3535
let classLists = await findClassListsInHtmlRange(state, doc, 'html')
3636

packages/tailwindcss-language-service/src/util/state.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export type ClassNameMeta = {
173173
context: string[]
174174
}
175175

176-
export function getDefaultTailwindSettings() {
176+
export function getDefaultTailwindSettings(): Settings {
177177
return {
178178
editor: { tabSize: 2 },
179179
tailwindCSS: {
@@ -205,6 +205,34 @@ export function getDefaultTailwindSettings() {
205205
configFile: null,
206206
},
207207
},
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+
}
210238
}

0 commit comments

Comments
 (0)