Skip to content

Commit 1b04467

Browse files
authored
fix: prompt terminator replay giving bad suggestions (#225)
* 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]>
1 parent 9f91c72 commit 1b04467

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/isterm/commandManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export class CommandManager {
5454
}
5555

5656
handlePromptEnd() {
57+
if (this.#activeCommand.promptEndMarker != null) return;
58+
5759
this.#activeCommand.promptEndMarker = this.#terminal.registerMarker(0);
5860
if (this.#activeCommand.promptEndMarker?.line === this.#terminal.buffer.active.cursorY) {
5961
this.#activeCommand.promptEndX = this.#terminal.buffer.active.cursorX;
@@ -275,7 +277,8 @@ export class CommandManager {
275277
}
276278
}
277279

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

281284
let cell = undefined;
@@ -288,7 +291,7 @@ export class CommandManager {
288291
}
289292
}
290293

291-
const commandPostfix = this.#activeCommand.promptText.length + command.trim().length < this.#terminal.buffer.active.cursorX ? " " : "";
294+
const commandPostfix = this.#activeCommand.promptText.length + command.trimEnd().length < this.#terminal.buffer.active.cursorX ? " " : "";
292295
this.#activeCommand.persistentOutput = this.#activeCommand.hasOutput && hasOutput;
293296
this.#activeCommand.hasOutput = hasOutput;
294297
this.#activeCommand.suggestionsText = suggestions.trim();

0 commit comments

Comments
 (0)