Skip to content

Commit 6e625ec

Browse files
authored
fix(codewhisperer): Sometimes not show recommendation bug in new inline code path (#2909)
## Problem Fix a critical bug that were introduced in f82944e When changing the hover config in inlineCompletionService, a document text close event will be sent and received by the listener in activation.ts, which removed the recommendations. This bug will make new inline completion not showing the recommendation if there is only one recommendation in paginated response. No changelog item is needed for this fix. ## Solution Let the doc close listener only remove recommendation when the closed file is the invocation file.
1 parent 6ab0e54 commit 6e625ec

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/codewhisperer/activation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export async function activate(context: ExtContext): Promise<void> {
174174
acceptSuggestion.register(context),
175175
// on text document close.
176176
vscode.workspace.onDidCloseTextDocument(e => {
177+
if (isInlineCompletionEnabled() && e.uri.fsPath !== InlineCompletionService.instance.filePath()) return
177178
RecommendationHandler.instance.reportUserDecisionOfCurrentRecommendation(vscode.window.activeTextEditor, -1)
178179
RecommendationHandler.instance.clearRecommendations()
179180
}),

src/codewhisperer/service/inlineCompletionService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ export class InlineCompletionService {
191191
return (this.#instance ??= new this())
192192
}
193193

194+
filePath(): string | undefined {
195+
return this.documentUri?.fsPath
196+
}
197+
194198
// These commands override the vs code inline completion commands
195199
// They are subscribed when suggestion starts and disposed when suggestion is accepted/rejected
196200
// to avoid impacting other plugins or user who uses this API

0 commit comments

Comments
 (0)