Scroll position often snaps to mid-window when typing #6871

Closed
opened 2026-01-31 00:49:27 +00:00 by claunia · 6 comments
Owner

Originally created by @randomascii on GitHub (Mar 14, 2020).

Environment

Windows Terminal version (if applicable): Windows Terminal (Preview)
Version: 0.9.433.0

Any other software? None applicable

Steps to reproduce

Run "dir" a few times to get a few hundred lines of output.
Resize the terminal window vertically (making it bigger). Then start typing. In many cases (I'm not exactly sure when) the current line will snap to somewhere in the middle of the window. It appears to be jumping to the bottom of the previous window position. Once a few commands are run and more output is printed it allows itself to go to the bottom

Expected behavior

When I start typing it shouldn't scroll the text unless that is necessary to make the cursor visible. Currently the terminal's notion of "visible" seems to be based on the previous window size.

Actual behavior

The content of the window scrolls up. This is quite disconcerting, and means that less relevant information is displayed.

Originally created by @randomascii on GitHub (Mar 14, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: Yes 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Environment ```Microsoft Windows [Version 10.0.18362.719] Windows Terminal version (if applicable): Windows Terminal (Preview) Version: 0.9.433.0 Any other software? None applicable ``` # Steps to reproduce Run "dir" a few times to get a few hundred lines of output. Resize the terminal window vertically (making it bigger). Then start typing. In many cases (I'm not exactly sure when) the current line will snap to somewhere in the middle of the window. It appears to be jumping to the bottom of the previous window position. Once a few commands are run and more output is printed it allows itself to go to the bottom # Expected behavior When I start typing it shouldn't scroll the text unless that is necessary to make the cursor visible. Currently the terminal's notion of "visible" seems to be based on the previous window size. # Actual behavior The content of the window scrolls up. This is quite disconcerting, and means that less relevant information is displayed.
Author
Owner

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

I think we knocked out a bunch of these with #4741 and (to be merged) #4903, the first of which is definitely in for 0.10. I'm going to mark this one for feedback and hold it until 0.10 is out to see if it's still a problem.

@DHowett-MSFT commented on GitHub (Mar 14, 2020): I think we knocked out a bunch of these with #4741 and (to be merged) #4903, the first of which is definitely in for 0.10. I'm going to mark this one for feedback and hold it until 0.10 is out to see if it's still a problem.
Author
Owner

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

This issue seams gone for me when I uninstalled the Windows Terminal and reinstalled version 0.10

@fullenw1 commented on GitHub (Mar 18, 2020): This issue seams gone for me when I uninstalled the Windows Terminal and reinstalled version 0.10
Author
Owner

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

Awesome, thanks for following up!

@zadjii-msft commented on GitHub (Mar 18, 2020): Awesome, thanks for following up!
Author
Owner

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

They still happen for me. Steps:

  1. Make sure you're running the 0.10 version
  2. Open the terminal and do something to generate some output, enough to more than fill the window
  3. Size the window to larger. then use the mouse-wheel to move the entry line down to the bottom or below
  4. Start typing - the entry line snaps back up to the bottom of the old Window size

It seems to correct itself more easily now, so the problem is less severe, but the problem is not gone.

@randomascii commented on GitHub (Mar 18, 2020): They still happen for me. Steps: 1) Make sure you're running the 0.10 version 2) Open the terminal and do something to generate some output, enough to more than fill the window 3) Size the window to larger. then use the mouse-wheel to move the entry line down to the bottom or below 4) Start typing - the entry line snaps back up to the bottom of the *old* Window size It seems to correct itself more easily now, so the problem is less severe, but the problem is not gone.
Author
Owner

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

I'm pretty sure we're not really going to be able to fix that one unfortunately. This is a complicated issue, so bear with me here.

When the Terminal is running commandline applications, it's running attached to an actual conhost instance that's hosting the Win32 console application. We need this so that Win32 APIs will still work in the Terminal. We call this conhost instance "conpty". This conpty has its own text buffer that's the size of the terminal's viewport. For the Terminal to properly display win32 applications, it's very important that the contents of the Terminal's viewport exactly matches the contents of conpty's buffer. If these two get out-of-sync, then the differences will become cumulative, and the contents of the Terminal might get horribly corrupted.

When you resize the Terminal, the terminal requests that conpty also resizes it's own buffer. When that happens, the terminal needs to react in a way that exactly matches how conpty reacts to the resize. As of #4741, the Terminal does a really good job of staying in sync with conpty. The Terminal moves it's viewport within the buffer so that the mutable part of the Terminal buffer still exactly matches the conpty buffer.

Unfortunately, conpty doesn't have any concept of a scrollback, so when it resizes, it can't magically summon lines back from the scrollback. If you just make conpty bigger, it's just going to add blank lines to the bottom of it's buffer. So when you make the Terminal taller, the conpty buffer looks like this:

  +------+       +------+
  |A     |       |A     |
  |B     | +-->  |B     |
  |C_    |       |C_    |
  |      |       |      |
  +------+       |      |
                 |      |
                 +------+

This then pairs with the Terminal snapping on input. When you type a character on the input line, the Terminal by default snaps back to the mutable viewport. Let's imagine that you had two lines of scrollback, with '1' and '2' in them. From the terminal's point of view, this is what's happening when you scroll up to make them visible, then increase the height of the buffer, then type a character.

          Conpty
                    +------+       +------+
                    |A     |       |A     |
                    |B     | +-->  |B     |
                    |C_    |       |C_    |
                    |      |       |      |
                    +------+       |      |
                                   |      |
                                   +------+
          +---------------------------------------+
         Terminal
                    +------+                   +------+                 +------+
          Visible+> |1     |         Visible+> |1     |     Visible     |1     |
                 |  |2     |                |  |2     |     = Mutable   |2     |
      Mutable+>  |  | ---- |     Mutable+>  |  | ---- |             +>  | ---- |
             |   |  |A     |            |   |  |A     |             |   |A     |
             |   |  |B     |            |   |  |B     |             |   |B     |
             |   +> |C_    |   +----->  |   |  |C_    |  +--->      |   |C_    |
             |      |      |  Increase  |   |  |      |  Type       |   |      |
             +>     +------+  Height    |   +> |      |  Input      |   |      |
                                        |      |      |             |   |      |
                                        +>     +------+             +>  +------+

You might be able to work around this with "snapOnInput": false in your profile settings, which will disable the snapping down on input.

@zadjii-msft commented on GitHub (Mar 18, 2020): I'm pretty sure we're not _really_ going to be able to fix that one unfortunately. This is a complicated issue, so bear with me here. When the Terminal is running commandline applications, it's running attached to an actual conhost instance that's hosting the Win32 console application. We need this so that Win32 APIs will still work in the Terminal. We call this conhost instance "conpty". This conpty has its own text buffer that's the size of the terminal's viewport. For the Terminal to properly display win32 applications, it's very important that the contents of the Terminal's viewport exactly matches the contents of conpty's buffer. If these two get out-of-sync, then the differences will become cumulative, and the contents of the Terminal might get horribly corrupted. When you resize the Terminal, the terminal requests that conpty also resizes it's own buffer. When that happens, the terminal needs to react in a way that exactly matches how conpty reacts to the resize. As of #4741, the Terminal does a _really good_ job of staying in sync with conpty. The Terminal moves it's viewport within the buffer so that the mutable part of the Terminal buffer still exactly matches the conpty buffer. Unfortunately, conpty doesn't have any concept of a scrollback, so when it resizes, it can't magically summon lines back from the scrollback. If you just make conpty bigger, it's just going to add blank lines to the bottom of it's buffer. So when you make the Terminal taller, the conpty buffer looks like this: ``` +------+ +------+ |A | |A | |B | +--> |B | |C_ | |C_ | | | | | +------+ | | | | +------+ ``` This then pairs with the Terminal snapping on input. When you type a character on the input line, the Terminal by default snaps back to the mutable viewport. Let's imagine that you had two lines of scrollback, with '1' and '2' in them. From the terminal's point of view, this is what's happening when you scroll up to make them visible, then increase the height of the buffer, then type a character. ``` Conpty +------+ +------+ |A | |A | |B | +--> |B | |C_ | |C_ | | | | | +------+ | | | | +------+ +---------------------------------------+ Terminal +------+ +------+ +------+ Visible+> |1 | Visible+> |1 | Visible |1 | | |2 | | |2 | = Mutable |2 | Mutable+> | | ---- | Mutable+> | | ---- | +> | ---- | | | |A | | | |A | | |A | | | |B | | | |B | | |B | | +> |C_ | +-----> | | |C_ | +---> | |C_ | | | | Increase | | | | Type | | | +> +------+ Height | +> | | Input | | | | | | | | | +> +------+ +> +------+ ``` You might be able to work around this with `"snapOnInput": false` in your profile settings, which will disable the snapping down on input.
Author
Owner

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

I can live with it, although it's slightly worrisome when a real fix is impossible.

@randomascii commented on GitHub (Mar 18, 2020): I can live with it, although it's slightly worrisome when a real fix is impossible.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6871