Enabling "Disable Scroll-Forward" causes incorrect display of vertical scrollbar #3445

Closed
opened 2026-01-30 23:21:26 +00:00 by claunia · 13 comments
Owner

Originally created by @rivy on GitHub (Aug 16, 2019).

Environment

Microsoft Windows [Version 10.0.18362.239]

Steps to reproduce

In a standard CMD console window, from the properties dialog:

  1. Terminal ~ ENABLE "Disable Scroll-Forward"
  2. Layout ~ decrease "Screen Buffer Size / Height" to be equal to "Window Size / Height"

Expected behavior

The vertical scrollbar should disappear.

Actual behavior

The vertical scrollbar remains, fully or partially obscuring the last column of text characters (depending on font/size?).

Screenshot

The obscuring behavior can be seen on the longer lines in the screenshot.

Originally created by @rivy on GitHub (Aug 16, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 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! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Microsoft Windows [Version 10.0.18362.239] ``` # Steps to reproduce In a standard CMD console window, from the properties dialog: 1. Terminal ~ ENABLE "Disable Scroll-Forward" 1. Layout ~ decrease "Screen Buffer Size / Height" to be equal to "Window Size / Height" # Expected behavior The vertical scrollbar should disappear. # Actual behavior The vertical scrollbar remains, fully or partially obscuring the last column of text characters (depending on font/size?). ![Screenshot](https://user-images.githubusercontent.com/80132/63137052-45e4c480-bf9a-11e9-8403-e0b9628a50cd.png) The obscuring behavior can be seen on the longer lines in the screenshot.
Author
Owner

@rivy commented on GitHub (Aug 16, 2019):

Parenthetically, I'm trying to enable a work-around for this bug for less, but I see no way to detect the "Disable Scroll-Forward" feature.

Is there any way to detect whether this or other features are enabled?

@rivy commented on GitHub (Aug 16, 2019): Parenthetically, I'm trying to enable a work-around for this bug for [`less`](https://github.com/rivy/less), but I see no way to detect the "Disable Scroll-Forward" feature. Is there any way to detect whether this or other features are enabled?
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 16, 2019):

This bug aside, the better way for less to ensure that there is no scrollbar (or one doesn't take up active screen space) is for it to use the (xterm) alternate buffer. That thing is really cool: it snapshots the display state, contents, etc. and switches the terminal emulator to a new pristine empty buffer that has no history and cannot scroll. When you exit the alt buffer, everything that was being displayed before snaps right back into place and overwrites the application's output.

@DHowett-MSFT commented on GitHub (Aug 16, 2019): This bug aside, the better way for `less` to ensure that there is no scrollbar (or one doesn't take up active screen space) is for it to use the (xterm) _alternate buffer_. That thing is really cool: it snapshots the display state, contents, etc. and switches the terminal emulator to a new pristine empty buffer that has no history and cannot scroll. When you exit the alt buffer, everything that was being displayed before snaps right back into place and overwrites the application's output.
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 16, 2019):

It's also a little more "standards-compliant" than SetConsoleActiveScreenBuffer.

@DHowett-MSFT commented on GitHub (Aug 16, 2019): It's also a little more "standards-compliant" than `SetConsoleActiveScreenBuffer`.
Author
Owner

@rivy commented on GitHub (Aug 18, 2019):

@DHowett-MSFT , thanks. I'll look into it.

I've hacked a work-around, for the time being, by just increasing the screen buffer vertical size by window size + one to force a scrollbar. All characters are displayed and the application function is unaffected, even if the scrollbar is redundant.

@rivy commented on GitHub (Aug 18, 2019): @DHowett-MSFT , thanks. I'll look into it. I've hacked a work-around, for the time being, by just increasing the screen buffer vertical size by window size + one to force a scrollbar. All characters are displayed and the application function is unaffected, even if the scrollbar is redundant.
Author
Owner

@rivy commented on GitHub (Oct 13, 2022):

This, after 3+ years, seems to be a won't-fix.
Please open as a new issue elsewhere if/when you want to fix it.

@rivy commented on GitHub (Oct 13, 2022): This, after 3+ years, seems to be a `won't-fix`. Please open as a new issue elsewhere if/when you want to fix it.
Author
Owner

@DHowett commented on GitHub (Oct 13, 2022):

I'm sorry about that. In the time since this was filed, I believe we improved the "disable scroll-forward" feature (which we had been calling "virtual bottom") in a number of ways... but none of those changes are, or will be, released to Windows 10. We never found a specific cause for this, nor did we get a strong local repro (which is puzzling)...

I'd love to know if it's still happening. I also respect that you may not want to engage with us about it any longer 🙂

@DHowett commented on GitHub (Oct 13, 2022): I'm sorry about that. In the time since this was filed, I believe we improved the "disable scroll-forward" feature (which we had been calling "virtual bottom") in a number of ways... but none of those changes are, or will be, released to Windows 10. We never found a specific cause for this, nor did we get a strong local repro (which is puzzling)... I'd love to know if it's still happening. I also respect that you may not want to engage with us about it any longer 🙂
Author
Owner

@j4james commented on GitHub (Oct 16, 2022):

@DHowett I can reproduce this (on Windows 10), but it looks to me like it might be a bug in the scrollbar implementation itself. Quoting the documentation here:

The system also hides and disables a standard scroll bar if you specify a page size that includes the entire scroll range of the scroll bar.

But that doesn't seem to be the case. I can get it to work if I manually hide the scrollbar when we're setting the scroll range, and the page size is greater than the max value (i.e. it includes the entire range). So something like this:

const auto scrollBarVisible = static_cast<int>(pageSize) <= maxSize;
ShowScrollBar(_hWnd, isVertical ? SB_VERT : SB_HORZ, scrollBarVisible);

inserted in the Window::UpdateScrollBar method here:

6567201e0e/src/interactivity/win32/window.cpp (L890-L898)

I'm not sure if that's exactly what we want, or there's a better way of fixing it, but that at least feels like an improvement.

If this is a Windows bug though, and it has already been fixed in Windows 11, then I assume there is no point in trying to fix it in our code (assuming Windows 10 isn't getting updates anymore).

@j4james commented on GitHub (Oct 16, 2022): @DHowett I can reproduce this (on Windows 10), but it looks to me like it might be a bug in the scrollbar implementation itself. Quoting the documentation [here](https://learn.microsoft.com/en-us/windows/win32/controls/about-scroll-bars#scroll-bar-visibility): > The system also hides and disables a standard scroll bar if you specify a page size that includes the entire scroll range of the scroll bar. But that doesn't seem to be the case. I can get it to work if I manually hide the scrollbar when we're setting the scroll range, and the page size is greater than the max value (i.e. it includes the entire range). So something like this: ```cpp const auto scrollBarVisible = static_cast<int>(pageSize) <= maxSize; ShowScrollBar(_hWnd, isVertical ? SB_VERT : SB_HORZ, scrollBarVisible); ``` inserted in the `Window::UpdateScrollBar` method here: https://github.com/microsoft/terminal/blob/6567201e0e1e72f82bfd3b565a8c3cb95ef2a75d/src/interactivity/win32/window.cpp#L890-L898 I'm not sure if that's exactly what we want, or there's a better way of fixing it, but that at least feels like an improvement. If this is a Windows bug though, and it has already been fixed in Windows 11, then I assume there is no point in trying to fix it in our code (assuming Windows 10 isn't getting updates anymore).
Author
Owner

@DHowett commented on GitHub (Oct 17, 2022):

@j4james, I'm more than happy to take your suggestion on a fix for this! It does still reproduce in Windows 11 conhost. Thanks for investigating. 😄

(We may want to make certain that scrollBarVisible is actually TRUE or FALSE; I've seen Win32 APIs get up to no good when confronted with non-Win32-BOOL booleans.)

EDIT: (Ah, that parameter controls redraw, not visibility. Hmm.)

@DHowett commented on GitHub (Oct 17, 2022): @j4james, I'm more than happy to take your suggestion on a fix for this! It does still reproduce in Windows 11 conhost. Thanks for investigating. :smile: (We may want to make certain that `scrollBarVisible` is actually `TRUE` or `FALSE`; I've seen Win32 APIs get up to no good when confronted with non-Win32-BOOL booleans.) EDIT: (Ah, that parameter controls _redraw_, not visibility. Hmm.)
Author
Owner

@j4james commented on GitHub (Oct 17, 2022):

EDIT: (Ah, that parameter controls redraw, not visibility. Hmm.)

@DHowett Just to be clear, I wasn't suggesting changing the final parameter of the SetScrollInfo call (that's the redraw flag). I'm suggesting adding an additional call to ShowScrollBar.

@j4james commented on GitHub (Oct 17, 2022): > EDIT: (Ah, that parameter controls _redraw_, not visibility. Hmm.) @DHowett Just to be clear, I wasn't suggesting changing the final parameter of the `SetScrollInfo` call (that's the _redraw_ flag). I'm suggesting adding an additional call to [`ShowScrollBar`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showscrollbar).
Author
Owner

@DHowett commented on GitHub (Oct 17, 2022):

Oh. Derp. Sorry 😄

@DHowett commented on GitHub (Oct 17, 2022): Oh. Derp. Sorry :smile:
Author
Owner

@j4james commented on GitHub (Nov 3, 2022):

I've been investigating this some more, and I think the solution is easier than I first thought. As I mentioned above, the scrollbar is actually meant to hide itself automatically. The reason why it isn't doing so in this case is because we are setting the SIF_DISABLENOSCROLL option on line 892.

It may look like that should only happen when in the alt buffer, but we're also setting the isAltBuffer parameter to true when the Disable Scroll-Forward options is set (i.e. IsTerminalScrolling is true). See here:

ed27737233/src/host/screenInfo.cpp (L684-L688)

Removing gci.IsTerminalScrolling() from line 685 fixes the problem.

I'm guessing the reason that was originally added was for the more typical usage where the buffer size is larger than the viewport. So initially the viewport wouldn't be scrollable until your content filled the window, and it probably seemed nicer to have the scrollbar initially visible and disabled rather than invisible, when it's expecting to become visible later. And while I agree that that would be nice, I think fixing this issue is more important.

I've now submitted that proposed fix in PR #14329.

@j4james commented on GitHub (Nov 3, 2022): I've been investigating this some more, and I think the solution is easier than I first thought. As I mentioned above, the scrollbar is actually meant to hide itself automatically. The reason why it isn't doing so in this case is because we are setting the `SIF_DISABLENOSCROLL` option on line 892. It may look like that should only happen when in the alt buffer, but we're also setting the `isAltBuffer` parameter to true when the *Disable Scroll-Forward* options is set (i.e. `IsTerminalScrolling` is true). See here: https://github.com/microsoft/terminal/blob/ed27737233714dea77877624d1beeb49e2ccd36e/src/host/screenInfo.cpp#L684-L688 Removing `gci.IsTerminalScrolling()` from line 685 fixes the problem. I'm guessing the reason that was originally added was for the more typical usage where the buffer size is larger than the viewport. So initially the viewport wouldn't be scrollable until your content filled the window, and it probably seemed nicer to have the scrollbar initially visible and disabled rather than invisible, when it's expecting to become visible later. And while I agree that that would be nice, I think fixing this issue is more important. I've now submitted that proposed fix in PR #14329.
Author
Owner

@DHowett commented on GitHub (Nov 3, 2022):

I'm totally on board with this fix. Thank you for investigating it!

@DHowett commented on GitHub (Nov 3, 2022): I'm totally on board with this fix. Thank you for investigating it!
Author
Owner

@ghost commented on GitHub (Jan 24, 2023):

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

Handy links:

@ghost commented on GitHub (Jan 24, 2023): :tada:This issue was addressed in #14329, which has now been successfully released as `Windows Terminal Preview v1.17.1023`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.17.1023) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3445