Skip to content

Commit 4c4c692

Browse files
committed
Don't trim whitespace when calculating cursor index
Fixes #260746
1 parent dafc6c5 commit 4c4c692

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
301301
let ghostTextIndex = -1;
302302
if (cursorIndex === undefined) {
303303
if (absoluteCursorY === commandStartY) {
304-
cursorIndex = this._getRelativeCursorIndex(this._commandStartX, buffer, line);
304+
cursorIndex = Math.min(this._getRelativeCursorIndex(this._commandStartX, buffer, line), commandLine.length);
305305
} else {
306306
cursorIndex = commandLine.trimEnd().length;
307307
}
@@ -628,7 +628,7 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
628628
}
629629

630630
private _getRelativeCursorIndex(startCellX: number, buffer: IBuffer, line: IBufferLine): number {
631-
return line?.translateToString(true, startCellX, buffer.cursorX).length ?? 0;
631+
return line?.translateToString(false, startCellX, buffer.cursorX).length ?? 0;
632632
}
633633

634634
private _isCellStyledLikeGhostText(cell: IBufferCell): boolean {

0 commit comments

Comments
 (0)