Skip to content

Commit 0eee159

Browse files
committed
update
1 parent 682100a commit 0eee159

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

packages/core/src/amazonq/lsp/lspController.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,28 +194,37 @@ export class LspController {
194194
}
195195
})
196196
}
197-
197+
/**
198+
* Updates context command symbols once per session by synchronizing with the LSP client index.
199+
* Context menu will contain file and folders to begin with,
200+
* then this asynchronous function should be invoked after the files and folders are found
201+
* the LSP then further starts to parse workspace and find symbols, which takes
202+
* anywhere from 5 seconds to about 40 seconds, depending on project size.
203+
* @returns {Promise<void>}
204+
*/
198205
async updateContextCommandSymbolsOnce() {
199206
if (this._contextCommandSymbolsUpdated) {
200207
return
201208
}
202209
this._contextCommandSymbolsUpdated = true
203210
getLogger().debug(`LspController: Start adding symbols to context picker menu`)
204-
const indexSeqNum = await LspClient.instance.getIndexSequenceNumber()
205-
await LspClient.instance.updateIndex([], 'context_command_symbol_update')
206-
await waitUntil(
207-
async () => {
208-
const newIndexSeqNum = await LspClient.instance.getIndexSequenceNumber()
209-
if (newIndexSeqNum > indexSeqNum) {
210-
await vscode.commands.executeCommand(`aws.amazonq.updateContextCommandItems`)
211-
this._contextCommandSymbolsUpdated = true
212-
return true
213-
}
214-
this._contextCommandSymbolsUpdated = false
215-
return false
216-
},
217-
{ interval: 1000, timeout: 60_000, truthy: true }
218-
)
211+
try {
212+
const indexSeqNum = await LspClient.instance.getIndexSequenceNumber()
213+
await LspClient.instance.updateIndex([], 'context_command_symbol_update')
214+
await waitUntil(
215+
async () => {
216+
const newIndexSeqNum = await LspClient.instance.getIndexSequenceNumber()
217+
if (newIndexSeqNum > indexSeqNum) {
218+
await vscode.commands.executeCommand(`aws.amazonq.updateContextCommandItems`)
219+
return true
220+
}
221+
return false
222+
},
223+
{ interval: 1000, timeout: 60_000, truthy: true }
224+
)
225+
} finally {
226+
this._contextCommandSymbolsUpdated = false
227+
}
219228
}
220229

221230
private async setupLsp(context: vscode.ExtensionContext) {

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ export class ChatController {
552552
}
553553

554554
this.messenger.sendContextCommandData(contextCommand)
555-
LspController.instance.updateContextCommandSymbolsOnce()
555+
void LspController.instance.updateContextCommandSymbolsOnce()
556556
}
557557

558558
private handlePromptCreate(tabID: string) {

0 commit comments

Comments
 (0)