Skip to content

Commit c28610d

Browse files
authored
Fix #19390: Make snap-on-input conditional to prevent blocking programmatic scroll (#19414)
## Summary of the Pull Request This PR fixes a bug where programmatic scrolling would get stuck. The fix makes the "snap-on-input" feature conditional, activating it only for modern applications that use Virtual Terminal (VT) processing. This restores correct scrolling behavior for legacy applications without removing the feature for new ones. ## References and Relevant Issues Fixes #19390: OpenConsole: Cursor visibility prevents programmatic scrolling ## Detailed Description of the Pull Request / Additional comments The "snap-on-input" feature introduced in a previous PR caused an unintended side effect for older console programs that use the SetConsoleWindowInfo API to manage their own viewport. When such a program tried to scroll using a key press, the snap feature would immediately pull the view back to the cursor's position, causing the screen to flicker and get stuck. This fix makes the snap-on-input feature smarter by checking the application's mode first. ## Validation Steps Performed Compiled the minimal C++ reproduction case from issue #19390. Ran the test executable inside the newly built OpenConsole.exe. Confirmed that scrolling with the Up/Down arrow keys now works correctly, even with a visible cursor. The view no longer flickers or gets stuck when the cursor moves outside the viewport. Closes #19390
1 parent 19a8501 commit c28610d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/host/input.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ void HandleGenericKeyEvent(INPUT_RECORD event, const bool generateBreak)
170170

171171
if (gci.HasActiveOutputBuffer())
172172
{
173-
gci.GetActiveOutputBuffer().SnapOnInput(keyEvent.wVirtualKeyCode);
173+
auto& buffer = gci.GetActiveOutputBuffer();
174+
175+
if (WI_IsFlagSet(buffer.OutputMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING))
176+
{
177+
buffer.SnapOnInput(keyEvent.wVirtualKeyCode);
178+
}
174179
}
175180
}
176181
}

0 commit comments

Comments
 (0)