Fix code suggestions gutter icon persisting across tabs
Description
In feat: Code suggestions gutter icon status (!1222 - merged) we added a gutter icon to indicate loading status of Code Suggestions.
This icon persists across changing tabs. Let's fix this.
Investigation
Let's consider this patch to fix this:
diff --git a/src/common/code_suggestions/code_suggestions_gutter_icon.ts b/src/common/code_suggestions/code_suggestions_gutter_icon.ts
index 4a2c3c03..018604f8 100644
--- a/src/common/code_suggestions/code_suggestions_gutter_icon.ts
+++ b/src/common/code_suggestions/code_suggestions_gutter_icon.ts
@@ -50,6 +50,10 @@ export class CodeSuggestionsGutterIcon {
this.#update(this.#lastState);
}),
+ vscode.window.onDidChangeActiveTextEditor(() => {
+ this.#update(VisibleCodeSuggestionsState.READY);
+ }),
+
state.onDidChangeVisibleState(currentState => {
this.#update(currentState);
}),
We could also try to detect if that text editor has changed based on the event object we get from onDidChangeTextEditorSelection
. That would probably be more performant.
https://code.visualstudio.com/api/references/vscode-api#TextEditorSelectionChangeEvent
Context
The following discussion from !1222 (merged) should be addressed:
-
@ealcantara started a discussion: (+1 comment) small ux improvement (non blocking) @pslaughter I noticed a small ux issue. The gutter icon persists when switching tabs in the editor. As a result, it looks like the extension will provide a suggestion in the line of the newly active text editor window. I don't consider this a blocker so I've approved the MR. If you want to take a stab at fixing this, let me know. Otherwise, I'll proceed with merging the MR.