From e06b51e3cd9fbcc63658cb83fc499fb410da0fd0 Mon Sep 17 00:00:00 2001 From: Chapman Pendery <35637443+cpendery@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:04:01 -0500 Subject: [PATCH] fix: prompt detection on clears (#132) Signed-off-by: Chapman Pendery --- src/isterm/commandManager.ts | 3 +++ src/ui/ui-root.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/isterm/commandManager.ts b/src/isterm/commandManager.ts index 3503c85..4a3efbb 100644 --- a/src/isterm/commandManager.ts +++ b/src/isterm/commandManager.ts @@ -46,6 +46,9 @@ export class CommandManager { } } handlePromptStart() { + if (this.#activeCommand.promptStartMarker?.line == -1) { + this.#previousCommandLines = new Set(); + } this.#activeCommand = { promptStartMarker: this.#terminal.registerMarker(0), hasOutput: false, cursorTerminated: false }; } diff --git a/src/ui/ui-root.ts b/src/ui/ui-root.ts index c8574bd..787b8f8 100644 --- a/src/ui/ui-root.ts +++ b/src/ui/ui-root.ts @@ -36,6 +36,10 @@ export const render = async (shell: Shell) => { const newlines = Math.max((data.match(/\r/g) || []).length, (data.match(/\n/g) || []).length); const linesOfInterest = MAX_LINES + newlines; if (term.getCursorState().remainingLines <= previousSuggestionsRows) { + // handles when suggestions get loaded before shell output so you need to always clear below output as a precaution + if (term.getCursorState().remainingLines != 0) { + writeOutput(ansi.cursorHide + ansi.cursorSavePosition + eraseLinesBelow(linesOfInterest + 1) + ansi.cursorRestorePosition); + } writeOutput( data + ansi.cursorHide +