COOKED_READ tab completion is very wrong when the prompt is wrapped #6942

Closed
opened 2026-01-31 00:51:05 +00:00 by claunia · 6 comments
Owner

Originally created by @AnuthaDev on GitHub (Mar 18, 2020).

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.535]
Windows Terminal version (if applicable): 0.10.761.0

Steps to reproduce

  1. Open cmd in Terminal.
  2. Reduce the width to minimum (well, not minimum but small enough, as it occurs after crossing some threshold).
  3. Press and hold Tab.

Expected behavior

cmd cycles through the directories:

ezgif-5-366a3a796ac1

Actual behavior

The names of directories are printed in succession without erasing the previous name which leads to this:

Also, note that this behaviour is not unique to Terminal, the default command promt(cmd/conhost/conPTY??) also has this bug:

image

After resizing the terminal the text cannot be erased.

Originally created by @AnuthaDev on GitHub (Mar 18, 2020). # Environment Windows build number: Microsoft Windows [Version 10.0.18363.535] Windows Terminal version (if applicable): 0.10.761.0 # Steps to reproduce 1. Open cmd in Terminal. 2. Reduce the width to minimum (well, not minimum but small enough, as it occurs after crossing some threshold). 3. Press and hold Tab. # Expected behavior cmd cycles through the directories: ![ezgif-5-366a3a796ac1](https://user-images.githubusercontent.com/36439704/76931217-318cef80-690e-11ea-845c-e2cbf2eacb47.gif) # Actual behavior The names of directories are printed in succession without erasing the previous name which leads to this: ![](https://user-images.githubusercontent.com/36439704/76930157-db1eb180-690b-11ea-873b-18f50db871c3.png) Also, note that this behaviour is not unique to Terminal, the default command promt(cmd/conhost/conPTY??) also has this bug: ![image](https://user-images.githubusercontent.com/36439704/76930682-0fdf3880-690d-11ea-9f9f-7c9f9c8e1d1a.png) After resizing the terminal the text cannot be erased.
Author
Owner

@zadjii-msft commented on GitHub (Mar 18, 2020):

I'm not saying that this isn't a bug, but it definitely repros in conhost too, so it's not necessarily a conpty or terminal bug.

image

For me, the trick is to resize such that the line the prompt starts on reflows, then hold tab. I'm seeing this on the 10.0.19587.1001 conhost, so that's not a particularly new conhost either.

@zadjii-msft commented on GitHub (Mar 18, 2020): I'm not saying that this _isn't_ a bug, but it definitely repros in conhost too, so it's not necessarily a conpty or terminal bug. ![image](https://user-images.githubusercontent.com/18356694/76960761-1b6d3800-68ea-11ea-8e1e-55366f8b1997.png) For me, the trick is to resize such that the line the prompt starts on reflows, then hold <kbd>tab</kbd>. I'm seeing this on the ` 10.0.19587.1001` conhost, so that's not a particularly new conhost either.
Author
Owner

@AnuthaDev commented on GitHub (Mar 18, 2020):

Hey @zadjii-msft I was not saying that this is a bug in conpty, Its just that I have seen that word used in similar contexts and didn't actually know the name of the default console, so threw it in there.(Note the question marks)

@AnuthaDev commented on GitHub (Mar 18, 2020): Hey @zadjii-msft I was not saying that this *is* a bug in conpty, Its just that I have seen that word used in similar contexts and didn't actually know the name of the default console, so threw it in there.(Note the question marks)
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 19, 2020):

It looks like this reproduces as far back as RS4, and only impacts the first cooked_read line that wraps after the resize, so I'm going to move it from 21H1 to Backlog and yank Triage. P3.

Thanks all!

@DHowett-MSFT commented on GitHub (Mar 19, 2020): It looks like this reproduces as far back as RS4, and only impacts the first cooked_read line that wraps after the resize, so I'm going to move it from 21H1 to Backlog and yank Triage. P3. Thanks all!
Author
Owner

@piotrzarycki commented on GitHub (Mar 21, 2020):

can i take care of it :) ?

@piotrzarycki commented on GitHub (Mar 21, 2020): can i take care of it :) ?
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 21, 2020):

If you want to take a crack at it, by all means do!

@DHowett-MSFT commented on GitHub (Mar 21, 2020): If you want to take a crack at it, by all means do!
Author
Owner

@serd2011 commented on GitHub (Aug 30, 2022):

This has something to do with the actual resizing cuz launching conhost with small width (enough to wrap cd path) does not reproduce this. And resizing back to big width causes it to print over the cd path. Interestingly, just writing after resizing works fine.

I have a theory. When window is resizes screen buffer changes its width. This change is not communicated to the connected application. Then it receives tab press and tries to output result on the previous cursor position that is now out of bounds. This causes conhost to disregard the position and just append it to the end. This is in line with observed behavior when conhost is launched with a small width and resized to a bigger one. Cursor position stays the same and prints on top of the cd path.
But when user inputs the coordinates get send with it and it works.
But I might be completely misunderstanding how this even works.

https://user-images.githubusercontent.com/45919738/187336803-70ab2a20-bf27-452a-9cfe-442caaf7c63d.mp4

@serd2011 commented on GitHub (Aug 30, 2022): This has something to do with the actual resizing cuz launching conhost with small width (enough to wrap cd path) does not reproduce this. And resizing back to big width causes it to print over the cd path. Interestingly, just writing after resizing works fine. I have a theory. When window is resizes screen buffer changes its width. This change is not communicated to the connected application. Then it receives tab press and tries to output result on the previous cursor position that is now out of bounds. This causes conhost to disregard the position and just append it to the end. This is in line with observed behavior when conhost is launched with a small width and resized to a bigger one. Cursor position stays the same and prints on top of the cd path. But when user inputs the coordinates get send with it and it works. But I might be completely misunderstanding how this even works. https://user-images.githubusercontent.com/45919738/187336803-70ab2a20-bf27-452a-9cfe-442caaf7c63d.mp4
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6942