fix: reset index after getSuggestions (#182)

This commit is contained in:
Alan.He
2024-03-04 17:20:12 -08:00
committed by GitHub
parent d2b1333006
commit 5c78bf4974
+2 -1
View File
@@ -48,6 +48,7 @@ export class SuggestionManager {
const commandText = this.#term.getCommandState().commandText;
if (!commandText) {
this.#suggestBlob = undefined;
this.#activeSuggestionIdx = 0;
return;
}
if (commandText == this.#command) {
@@ -56,6 +57,7 @@ export class SuggestionManager {
this.#command = commandText;
const suggestionBlob = await getSuggestions(commandText, this.#term.cwd, this.#shell);
this.#suggestBlob = suggestionBlob;
this.#activeSuggestionIdx = 0;
}
private _renderArgumentDescription(description: string | undefined, x: number) {
@@ -88,7 +90,6 @@ export class SuggestionManager {
async render(remainingLines: number): Promise<SuggestionsSequence> {
await this._loadSuggestions();
if (!this.#suggestBlob) {
this.#activeSuggestionIdx = 0;
return { data: "", rows: 0 };
}
const { suggestions, argumentDescription } = this.#suggestBlob;