Skip to content

Preserve rows below partial scroll regions#10

Merged
tomlm merged 6 commits into
tomlm:mainfrom
jchristn:fix/top-anchored-scroll-region
Jun 21, 2026
Merged

Preserve rows below partial scroll regions#10
tomlm merged 6 commits into
tomlm:mainfrom
jchristn:fix/top-anchored-scroll-region

Conversation

@jchristn

@jchristn jchristn commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Treat only full-screen scroll regions as eligible for scrollback promotion
  • Keep top-anchored partial scroll regions in-place so rows below the bottom margin are preserved
  • Use active-buffer coordinates for IL / CSI Ps L and DL / CSI Ps M when normal-buffer scrollback exists
  • Ignore DL / CSI Ps M when the cursor is outside the scroll region, matching IL
  • Add regression tests covering reserved bottom prompt/status rows

Why

Prompt-oriented terminal applications can reserve a bottom input/status row while scrolling output above it. A top-anchored partial scroll region must not promote the reserved row into scrollback.

The same visual artifact can occur after normal-buffer scrollback exists if insert/delete-line operations splice using viewport-relative ScrollBottom rather than YBase + ScrollBottom. In that case old scrollback rows can be edited instead of the active screen, allowing prompt/status content such as > or > to reappear higher in the viewport.

DL also needs the same scroll-region guard as IL; delete-line operations outside the active scroll region should be ignored so reserved prompt/status rows are not shifted.

Tests

  • dotnet test src\XTerm.NET.slnx

@jchristn jchristn marked this pull request as ready for review June 2, 2026 04:58
@jchristn jchristn force-pushed the fix/top-anchored-scroll-region branch from c193f32 to 2532dce Compare June 2, 2026 05:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts scroll/scrollback and insert/delete-line behavior to correctly preserve reserved rows (e.g., bottom prompt/status lines) when applications use top-anchored partial scroll regions, and to ensure IL/DL operations target the active screen when normal-buffer scrollback exists.

Changes:

  • Restrict scrollback promotion to full-screen scroll regions, keeping top-anchored partial regions scrolling in-place.
  • Use active-buffer (absolute) coordinates for IL (CSI Ps L) and DL (CSI Ps M) when YBase is non-zero, and ignore DL outside the scroll region (matching IL).
  • Add regression tests covering partial scroll regions and IL/DL behavior with scrollback and reserved prompt rows.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/XTerm.NET/InputHandler.cs Fixes IL/DL splice indices to use active-buffer coordinates and adds a scroll-region guard for DL.
src/XTerm.NET/Buffer/TerminalBuffer.cs Limits scrollback promotion to full-screen scroll regions so reserved rows below partial regions aren’t promoted.
src/XTerm.NET.Tests/Buffer/BufferTests.cs Adds regression tests for partial scroll regions and IL/DL behavior when scrollback exists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/XTerm.NET.Tests/Buffer/BufferTests.cs
Comment thread src/XTerm.NET.Tests/Buffer/BufferTests.cs
Comment thread src/XTerm.NET.Tests/Buffer/BufferTests.cs
@tomlm tomlm merged commit d517a43 into tomlm:main Jun 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants