fix: reset the selected completion index to 0 to prevent the selected… (#173)

* fix: reset the selected completion index to 0 to prevent the selected state from not being correctly initialized when the completion toggle.

* style: fix lint

Signed-off-by: Chapman Pendery <cpendery@microsoft.com>

---------

Signed-off-by: Chapman Pendery <cpendery@microsoft.com>
Co-authored-by: Chapman Pendery <cpendery@microsoft.com>
This commit is contained in:
Alan.He
2024-03-01 12:21:41 -08:00
committed by GitHub
co-authored by Chapman Pendery
parent 8fc1d03a5f
commit ddd79c5949
+4 -1
View File
@@ -87,7 +87,10 @@ export class SuggestionManager {
async render(remainingLines: number): Promise<SuggestionsSequence> {
await this._loadSuggestions();
if (!this.#suggestBlob) return { data: "", rows: 0 };
if (!this.#suggestBlob) {
this.#activeSuggestionIdx = 0;
return { data: "", rows: 0 };
}
const { suggestions, argumentDescription } = this.#suggestBlob;
const page = Math.min(Math.floor(this.#activeSuggestionIdx / maxSuggestions) + 1, Math.floor(suggestions.length / maxSuggestions) + 1);