Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "amazon q inline: skip indexing when no workspace folders are found"
}
19 changes: 6 additions & 13 deletions packages/core/src/amazonq/lsp/lspController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ import { isWeb } from '../../shared/extensionGlobals'
import { getUserAgent } from '../../shared/telemetry/util'
import { isAmazonInternalOs } from '../../shared/vscode/env'

function getProjectPaths() {
const workspaceFolders = vscode.workspace.workspaceFolders
if (!workspaceFolders || workspaceFolders.length === 0) {
throw new ToolkitError('No workspace folders found')
}
return workspaceFolders.map((folder) => folder.uri.fsPath)
}

export interface Chunk {
readonly filePath: string
readonly content: string
Expand Down Expand Up @@ -322,12 +314,13 @@ export class LspController {
async buildIndex(buildIndexConfig: BuildIndexConfig) {
getLogger().info(`LspController: Starting to build index of project`)
const start = performance.now()
const projPaths = getProjectPaths()
const projPaths = (vscode.workspace.workspaceFolders ?? []).map((folder) => folder.uri.fsPath)
if (projPaths.length === 0) {
getLogger().info(`LspController: Skipping building index. No projects found in workspace`)
return
}
projPaths.sort()
try {
if (projPaths.length === 0) {
throw Error('No project')
}
this._isIndexingInProgress = true
const projRoot = projPaths[0]
const files = await collectFilesForIndex(
Expand All @@ -340,7 +333,7 @@ export class LspController {
(accumulator, currentFile) => accumulator + currentFile.fileSizeBytes,
0
)
getLogger().info(`LspController: Found ${files.length} files in current project ${getProjectPaths()}`)
getLogger().info(`LspController: Found ${files.length} files in current project ${projPaths}`)
const config = buildIndexConfig.isVectorIndexEnabled ? 'all' : 'default'
const r = files.map((f) => f.fileUri.fsPath)
const resp = await LspClient.instance.buildIndex(r, projRoot, config)
Expand Down
Loading