Skip to content

Commit

Permalink
fix: prompt terminator replay giving bad suggestions (#225)
Browse files Browse the repository at this point in the history
* fix: prompt terminator replay giving bad suggestions

Signed-off-by: Chapman Pendery <[email protected]>

* style: fix formatting

Signed-off-by: Chapman Pendery <[email protected]>

---------

Signed-off-by: Chapman Pendery <[email protected]>
  • Loading branch information
cpendery authored Apr 8, 2024
1 parent 9f91c72 commit 1b04467
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/isterm/commandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export class CommandManager {
}

handlePromptEnd() {
if (this.#activeCommand.promptEndMarker != null) return;

this.#activeCommand.promptEndMarker = this.#terminal.registerMarker(0);
if (this.#activeCommand.promptEndMarker?.line === this.#terminal.buffer.active.cursorY) {
this.#activeCommand.promptEndX = this.#terminal.buffer.active.cursorX;
Expand Down Expand Up @@ -275,7 +277,8 @@ export class CommandManager {
}
}

const cursorAtEndOfInput = (this.#activeCommand.promptText.length + command.trim().length) % this.#terminal.cols <= this.#terminal.buffer.active.cursorX;
const cursorAtEndOfInput =
(this.#activeCommand.promptText.length + command.trimEnd().length) % this.#terminal.cols <= this.#terminal.buffer.active.cursorX;
let hasOutput = false;

let cell = undefined;
Expand All @@ -288,7 +291,7 @@ export class CommandManager {
}
}

const commandPostfix = this.#activeCommand.promptText.length + command.trim().length < this.#terminal.buffer.active.cursorX ? " " : "";
const commandPostfix = this.#activeCommand.promptText.length + command.trimEnd().length < this.#terminal.buffer.active.cursorX ? " " : "";
this.#activeCommand.persistentOutput = this.#activeCommand.hasOutput && hasOutput;
this.#activeCommand.hasOutput = hasOutput;
this.#activeCommand.suggestionsText = suggestions.trim();
Expand Down

0 comments on commit 1b04467

Please sign in to comment.