@@ -23,14 +23,6 @@ import { isWeb } from '../../shared/extensionGlobals'
2323import { getUserAgent } from '../../shared/telemetry/util'
2424import { isAmazonInternalOs } from '../../shared/vscode/env'
2525
26- function getProjectPaths ( ) {
27- const workspaceFolders = vscode . workspace . workspaceFolders
28- if ( ! workspaceFolders || workspaceFolders . length === 0 ) {
29- throw new ToolkitError ( 'No workspace folders found' )
30- }
31- return workspaceFolders . map ( ( folder ) => folder . uri . fsPath )
32- }
33-
3426export interface Chunk {
3527 readonly filePath : string
3628 readonly content : string
@@ -322,12 +314,13 @@ export class LspController {
322314 async buildIndex ( buildIndexConfig : BuildIndexConfig ) {
323315 getLogger ( ) . info ( `LspController: Starting to build index of project` )
324316 const start = performance . now ( )
325- const projPaths = getProjectPaths ( )
317+ const projPaths = ( vscode . workspace . workspaceFolders ?? [ ] ) . map ( ( folder ) => folder . uri . fsPath )
318+ if ( projPaths . length === 0 ) {
319+ getLogger ( ) . info ( `LspController: Skipping building index. No projects found in workspace` )
320+ return
321+ }
326322 projPaths . sort ( )
327323 try {
328- if ( projPaths . length === 0 ) {
329- throw Error ( 'No project' )
330- }
331324 this . _isIndexingInProgress = true
332325 const projRoot = projPaths [ 0 ]
333326 const files = await collectFilesForIndex (
@@ -340,7 +333,7 @@ export class LspController {
340333 ( accumulator , currentFile ) => accumulator + currentFile . fileSizeBytes ,
341334 0
342335 )
343- getLogger ( ) . info ( `LspController: Found ${ files . length } files in current project ${ getProjectPaths ( ) } ` )
336+ getLogger ( ) . info ( `LspController: Found ${ files . length } files in current project ${ projPaths } ` )
344337 const config = buildIndexConfig . isVectorIndexEnabled ? 'all' : 'default'
345338 const r = files . map ( ( f ) => f . fileUri . fsPath )
346339 const resp = await LspClient . instance . buildIndex ( r , projRoot , config )
0 commit comments