@@ -136,27 +136,35 @@ export class SessionManager {
136136 // Ideally use this API handleDidShowCompletionItem
137137 // https://github.com/microsoft/vscode/blob/main/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts#L83
138138 updateCodeReferenceAndImports ( ) {
139- this . clearReferenceInlineHintsAndImportHints ( )
140- if ( this . activeSession ?. suggestions && this . activeSession . suggestions . length > 0 ) {
141- const reference = this . activeSession . suggestions [ this . _currentSuggestionIndex ] . references
142- if ( reference && reference . length > 0 ) {
139+ try {
140+ this . clearReferenceInlineHintsAndImportHints ( )
141+ if (
142+ this . activeSession ?. suggestions &&
143+ this . activeSession . suggestions [ this . _currentSuggestionIndex ] &&
144+ this . activeSession . suggestions . length > 0
145+ ) {
146+ const reference = this . activeSession . suggestions [ this . _currentSuggestionIndex ] . references
143147 const insertText = this . activeSession . suggestions [ this . _currentSuggestionIndex ] . insertText
144- const insertTextStr =
145- typeof insertText === 'string' ? insertText : ( insertText . value ?? String ( insertText ) )
146-
147- ReferenceInlineProvider . instance . setInlineReference (
148- this . activeSession . startPosition . line ,
149- insertTextStr ,
150- reference
151- )
152- }
153- if ( vscode . window . activeTextEditor ) {
154- ImportAdderProvider . instance . onShowRecommendation (
155- vscode . window . activeTextEditor . document ,
156- this . activeSession . startPosition . line ,
157- this . activeSession . suggestions [ this . _currentSuggestionIndex ]
158- )
148+ if ( reference && reference . length > 0 ) {
149+ const insertTextStr =
150+ typeof insertText === 'string' ? insertText : ( insertText . value ?? String ( insertText ) )
151+
152+ ReferenceInlineProvider . instance . setInlineReference (
153+ this . activeSession . startPosition . line ,
154+ insertTextStr ,
155+ reference
156+ )
157+ }
158+ if ( vscode . window . activeTextEditor ) {
159+ ImportAdderProvider . instance . onShowRecommendation (
160+ vscode . window . activeTextEditor . document ,
161+ this . activeSession . startPosition . line ,
162+ this . activeSession . suggestions [ this . _currentSuggestionIndex ]
163+ )
164+ }
159165 }
166+ } catch {
167+ // do nothing as this is not critical path
160168 }
161169 }
162170}
0 commit comments