Some ScrollConsoleScreenBuffer directions have stopped working correctly #22162

Open
opened 2026-01-31 08:05:09 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Aug 26, 2024).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

Commit f93347ed4b

Windows build number

10.0.19045.4780

Other Software

No response

Steps to reproduce

Compile and run the following code in a recent build of Windows Terminal:

#include <windows.h>
#include <stdio.h>

void scroll(HANDLE h, int left, int top, int right, int bottom, int dx, int dy)
{
  SHORT x1 = min(left+dx, left);
  SHORT x2 = max(right+dx, right);
  SHORT y1 = min(top+dy, top);
  SHORT y2 = max(bottom+dy, bottom);
  SMALL_RECT rect = {x1-1, y1-1, x2-1, y2-1};
  SHORT ox = x1+dx-1;
  SHORT oy = y1+dy-1;
  CHAR_INFO fill = {'+', 0x56};
  ScrollConsoleScreenBuffer(h, &rect, &rect, {ox,oy}, &fill);
}

int main(int argc, char* argv[])
{
  DWORD mode;
  HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
  GetConsoleMode(h, &mode);
  mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
  SetConsoleMode(h, mode);

  printf("\033#8");

  scroll(h,39,8,42,10,0,-2);
  scroll(h,39,15,42,17,0,2);
  scroll(h,31,12,36,13,-4,0);
  scroll(h,45,12,50,13,4,0);

  SetConsoleMode(h, mode);
  return 0;
}

Expected Behavior

It should fill the screen with a DECALN pattern of E characters, and then scroll slices of that buffer up, down, left, and right, leaving four areas of purple with yellow + characters in the "erased" space revealed by the scrolling.

You should end up with a pattern something like this:

image

Actual Behavior

It looks like some of the scrolling directions aren't working correctly, so you only end up with two of the purple areas showing.

image

I'm guessing this might be caused by the new VT implementation of ScrollConsoleScreenBuffer from PR #17747.

Originally created by @j4james on GitHub (Aug 26, 2024). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version Commit f93347ed4bbeea0d9e663f2069994d9e2d069f10 ### Windows build number 10.0.19045.4780 ### Other Software _No response_ ### Steps to reproduce Compile and run the following code in a recent build of Windows Terminal: ```cpp #include <windows.h> #include <stdio.h> void scroll(HANDLE h, int left, int top, int right, int bottom, int dx, int dy) { SHORT x1 = min(left+dx, left); SHORT x2 = max(right+dx, right); SHORT y1 = min(top+dy, top); SHORT y2 = max(bottom+dy, bottom); SMALL_RECT rect = {x1-1, y1-1, x2-1, y2-1}; SHORT ox = x1+dx-1; SHORT oy = y1+dy-1; CHAR_INFO fill = {'+', 0x56}; ScrollConsoleScreenBuffer(h, &rect, &rect, {ox,oy}, &fill); } int main(int argc, char* argv[]) { DWORD mode; HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleMode(h, &mode); mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; SetConsoleMode(h, mode); printf("\033#8"); scroll(h,39,8,42,10,0,-2); scroll(h,39,15,42,17,0,2); scroll(h,31,12,36,13,-4,0); scroll(h,45,12,50,13,4,0); SetConsoleMode(h, mode); return 0; } ``` ### Expected Behavior It should fill the screen with a `DECALN` pattern of `E` characters, and then scroll slices of that buffer up, down, left, and right, leaving four areas of purple with yellow `+` characters in the "erased" space revealed by the scrolling. You should end up with a pattern something like this: ![image](https://github.com/user-attachments/assets/4f1a6fbd-1827-4fb0-beaf-e7470a88131d) ### Actual Behavior It looks like some of the scrolling directions aren't working correctly, so you only end up with two of the purple areas showing. ![image](https://github.com/user-attachments/assets/0c9915f0-7a9b-4b6b-80d1-d10d19cbd227) I'm guessing this might be caused by the new VT implementation of `ScrollConsoleScreenBuffer` from PR #17747.
claunia added the Issue-BugIn-PRArea-VTNeeds-Tag-FixProduct-Conpty labels 2026-01-31 08:05:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22162