terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Cursor droppings are back in conhost

Open j4james opened this issue 3 years ago • 5 comments

Windows Terminal version

OpenConsole 8a34a0e59ac41bc805c308fb82bc7683e583d45d

Windows build number

10.0.19041.1415

Other Software

No response

Steps to reproduce

  1. You must be using a somewhat recent version of OpenConsole.
  2. Open a WSL bash shell.
  3. Execute the following: printf "\e[2 q\e[9999C "; sleep 1

The CSI 2 q is to get a non-blinking cursor which makes the issue easier to produce. The CSI 9999C moves the cursor to the end of the line, and the space initiates a delayed wrap. The sleep then gives the cursor a chance to be rendered before the next output will trigger the actual wrap.

Expected Behavior

The output should wrap to the next line without leaving a visible cursor block behind.

Actual Behavior

The cursor at the end of the line isn't cleared when the output wraps, so you end up with two cursors visible on the screen.

image

This doesn't occur in my inbox version of conhost, so I think it might be a regression.

j4james avatar Mar 22 '22 10:03 j4james

DROP EVERYTHING, THEY'RE BACK.

Thanks for noticing! Definitely can't let these back into the world 😝

zadjii-msft avatar Mar 22 '22 10:03 zadjii-msft

I think this was broken by the deferred cursor drawing introduced in PR #10394. I can fix it by removing the StartDeferDrawing and EndDeferDrawing here:

https://github.com/microsoft/terminal/blob/f936c4443d4b7b11da32077b0dc0a9aa8652bc77/src/host/outputStream.cpp#L45-L55

But then we lose the performance improvements we were getting from the PR. Hopefully there's a way to fix it without undoing that completely.

j4james avatar Mar 22 '22 10:03 j4james

I've got a possible solution that doesn't require undoing the deferred drawing. We save the current cursor position in StartDeferDrawing, and then trigger a redraw for both the old and new positions in EndDeferDrawing (assuming the position has changed).

Hopefully the overhead of that additional maintenance doesn't outweigh the benefits we're getting from the deferred drawing, but I'm not the best person to evaluate the performance issues here. I'm also not positive this is going to work in all scenarios - need to play around with it some more.

j4james avatar Mar 22 '22 10:03 j4james

Fixing #12917 doesn't magically fix this 😢

Note: only repros when you're above the bottom of the viewport, so the view doesn't scroll

zadjii-msft avatar Apr 29 '22 14:04 zadjii-msft

Might get fixed by snapshots

zadjii-msft avatar Dec 05 '22 22:12 zadjii-msft

:tada:This issue was addressed in #14640, which has now been successfully released as Windows Terminal Preview v1.17.1023.:tada:

Handy links:

ghost avatar Jan 24 '23 18:01 ghost