mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
fix: stale suggestion appearing after command execution (#185)
Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
@@ -87,6 +87,11 @@ export class SuggestionManager {
|
||||
);
|
||||
}
|
||||
|
||||
validate(suggestion: SuggestionsSequence): SuggestionsSequence {
|
||||
const commandText = this.#term.getCommandState().commandText;
|
||||
return !commandText ? { data: "", rows: 0 } : suggestion;
|
||||
}
|
||||
|
||||
async render(remainingLines: number): Promise<SuggestionsSequence> {
|
||||
await this._loadSuggestions();
|
||||
if (!this.#suggestBlob) {
|
||||
|
||||
+3
-2
@@ -57,8 +57,9 @@ export const render = async (shell: Shell, underTest: boolean) => {
|
||||
writeOutput(data);
|
||||
}
|
||||
|
||||
setImmediate(async () => {
|
||||
const suggestion = await suggestionManager.render(term.getCursorState().remainingLines);
|
||||
process.nextTick(async () => {
|
||||
// validate result to prevent stale suggestion being provided
|
||||
const suggestion = suggestionManager.validate(await suggestionManager.render(term.getCursorState().remainingLines));
|
||||
const commandState = term.getCommandState();
|
||||
|
||||
if (suggestion.data != "" && commandState.cursorTerminated && !commandState.hasOutput) {
|
||||
|
||||
Reference in New Issue
Block a user