From ddd79c594936c8f2b61f1a1e347c6e8fb2279f74 Mon Sep 17 00:00:00 2001 From: "Alan.He" Date: Sat, 2 Mar 2024 04:21:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20reset=20the=20selected=20completion=20in?= =?UTF-8?q?dex=20to=200=20to=20prevent=20the=20selected=E2=80=A6=20(#173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --------- Signed-off-by: Chapman Pendery Co-authored-by: Chapman Pendery --- src/ui/suggestionManager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ui/suggestionManager.ts b/src/ui/suggestionManager.ts index e84a949..4570f77 100644 --- a/src/ui/suggestionManager.ts +++ b/src/ui/suggestionManager.ts @@ -87,7 +87,10 @@ export class SuggestionManager { async render(remainingLines: number): Promise { 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);