[PR #15880] Fix the prompt sometimes not being erased properly #30765

Open
opened 2026-01-31 09:42:49 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15880

State: closed
Merged: Yes


A carriage return (enter key) will increase the _distanceEnd by up to
viewport-width many columns, since it increases the Y distance between
the start and end by 1 (it's a newline after all).
This will make _flushBuffer() think that the new _buffer is way longer
than the old one and so _erase() ends up not erasing the tail end of
the prompt, even if the new prompt is actually shorter.

This commit fixes the issue by separating the newline printing
out from the regular text printing loops.

Validation Steps Performed

  • Run cmd.exe
  • Write "echo hello" and press Enter
  • Write "foobar foo bar" (don't press Enter)
  • Press F7, select "echo hello" and press Enter
  • Previous prompt says "echo hello"
**Original Pull Request:** https://github.com/microsoft/terminal/pull/15880 **State:** closed **Merged:** Yes --- A carriage return (enter key) will increase the _distanceEnd by up to viewport-width many columns, since it increases the Y distance between the start and end by 1 (it's a newline after all). This will make _flushBuffer() think that the new _buffer is way longer than the old one and so _erase() ends up not erasing the tail end of the prompt, even if the new prompt is actually shorter. This commit fixes the issue by separating the newline printing out from the regular text printing loops. ## Validation Steps Performed * Run cmd.exe * Write "echo hello" and press Enter * Write "foobar foo bar" (don't press Enter) * Press F7, select "echo hello" and press Enter * Previous prompt says "echo hello" ✅
claunia added the pull-request label 2026-01-31 09:42:49 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30765