@@ -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 ) {
0 commit comments