Cursor position is lost when resizing the window if not on the bottom line #14757

Open
opened 2026-01-31 04:18:41 +00:00 by claunia · 0 comments
Owner

Originally created by @daanx on GitHub (Aug 2, 2021).

Windows Terminal version (or Windows build number)

10.0.19042.1110 (windows terminal 1.9.1942.0)

Other Software

No response

Steps to reproduce

If the cursor position is not on the last line (of the input), making the screen more narrow will push the cursor down to the last line when lines wrap and the original position is lost; on a resize to make it wider again it stays on the last line.

This affects utilities like "readline" when editing multiple lines of input. Hope it can be fixed as it makes multiline editing not work at all.

To reproduce, run the following batch file:

@echo off
echo Resize the window to make it more narrow and wider again.
echo The cursor will lose its position and move down.
echo.
echo The cursor is first positioned at the start of this long line.
set /p "ANSWER=Press <enter> to stop .."
echo.
echo Thank you.

(note: I think the paste lost it but there should be an ESC character in front of the [ characters to make the escape sequence function; the ESC[1F moves the cursor one up so it is no longer on the last line.)

Expected Behavior

The cursor should always stay at the same point in the input regardless of a window resize. The "old" cmd terminal is correct and the cursor stays at the same point..

Actual Behavior

cursor-bug-cmd

Here you see the cursor in Windows Terminal (I made it red) move down a line on the resize and lose its position.

Originally created by @daanx on GitHub (Aug 2, 2021). ### Windows Terminal version (or Windows build number) 10.0.19042.1110 (windows terminal 1.9.1942.0) ### Other Software _No response_ ### Steps to reproduce If the cursor position is not on the last line (of the input), making the screen more narrow will push the cursor down to the last line when lines wrap and the original position is lost; on a resize to make it wider again it stays on the last line. This affects utilities like "readline" when editing multiple lines of input. Hope it can be fixed as it makes multiline editing not work at all. To reproduce, run the following batch file: ```bat @echo off echo Resize the window to make it more narrow and wider again. echo The cursor will lose its position and move down. echo. echo The cursor is first positioned at the start of this long line. set /p "ANSWER=Press <enter> to stop .." echo. echo Thank you. ``` (note: I think the paste lost it but there should be an `ESC` character in front of the `[` characters to make the escape sequence function; the `ESC[1F` moves the cursor one up so it is no longer on the last line.) ### Expected Behavior The cursor should always stay at the same point in the input regardless of a window resize. The "old" cmd terminal is correct and the cursor stays at the same point.. ### Actual Behavior ![cursor-bug-cmd](https://user-images.githubusercontent.com/2171100/127802782-ae3a8a8a-5d30-4dbd-92ac-e41ef3726d4a.png) Here you see the cursor in Windows Terminal (I made it red) move down a line on the resize and lose its position.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14757