File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ export interface VitestPackage {
3030
3131function resolveVitestConfig ( showWarning : boolean , configOrWorkspaceFile : vscode . Uri ) : VitestPackage | null {
3232 const folder = vscode . workspace . getWorkspaceFolder ( configOrWorkspaceFile ) !
33+ if ( ! folder )
34+ throw new Error ( `Workspace folder not found for ${ configOrWorkspaceFile } . Does the file exist?` )
35+
3336 const cwd = dirname ( configOrWorkspaceFile . fsPath )
3437 const vitest = resolveVitestPackage ( dirname ( configOrWorkspaceFile . fsPath ) , folder )
3538
Original file line number Diff line number Diff line change @@ -15,13 +15,10 @@ export function getConfigValue<T>(
1515}
1616
1717export function getConfig ( workspaceFolder ?: WorkspaceFolder ) {
18- let workspace : WorkspaceFolder | vscode . Uri | undefined
19- if ( typeof workspaceFolder === 'string' )
20- workspace = vscode . Uri . from ( { scheme : 'file' , path : workspaceFolder } )
21- else
22- workspace = workspaceFolder
18+ if ( ! workspaceFolder && vscode . workspace . workspaceFolders ?. length === 1 )
19+ workspaceFolder = vscode . workspace . workspaceFolders [ 0 ]
2320
24- const folderConfig = vscode . workspace . getConfiguration ( 'vitest' , workspace )
21+ const folderConfig = vscode . workspace . getConfiguration ( 'vitest' , workspaceFolder )
2522 const rootConfig = vscode . workspace . getConfiguration ( 'vitest' )
2623
2724 const get = < T > ( key : string , defaultValue ?: T ) => getConfigValue < T > (
You can’t perform that action at this time.
0 commit comments