Skip to content

Commit

Permalink
fix: prompt detection on clears (#132)
Browse files Browse the repository at this point in the history
Signed-off-by: Chapman Pendery <[email protected]>
  • Loading branch information
cpendery authored Dec 20, 2023
1 parent 724304c commit e06b51e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/isterm/commandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
4 changes: 4 additions & 0 deletions src/ui/ui-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down

0 comments on commit e06b51e

Please sign in to comment.