Skip to content

Move displaced line of top-anchored scroll region into scroll-back - #2764

Open
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:feature/terminal-scrollregion-history-2680
Open

vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:feature/terminal-scrollregion-history-2680

Conversation

@vogella

@vogella vogella commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Full-screen CLIs such as Codex in --no-alt-screen mode render through DECSTBM scroll regions anchored at the top of the screen and scroll by emitting newlines at the region bottom. The emulator scrolled such a region in place and discarded the displaced top line, so no scroll-back history was created and the output could not be scrolled backwards.

Like xterm and VTE, a newline at the bottom of a scroll region whose top margin is the top of the screen now moves the displaced top line into the scroll-back history, while the lines below the region keep their position on the screen. Regions with a lower top margin still scroll in place, guarded by the characterization tests from #2701; the test documenting the old top-anchored behavior is flipped to assert the history is created.

This addresses the missing backward scrolling reported in #2680.

@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   37m 53s ⏱️ -40s
 5 007 tests +3   4 985 ✅ +3   22 💤 ±0  0 ❌ ±0 
12 912 runs  +9  12 758 ✅ +9  154 💤 ±0  0 ❌ ±0 

Results for commit 9c5d82b. ± Comparison against base commit bc125e3.

This pull request removes 1 and adds 4 tests. Note that renamed tests count towards both.
org.eclipse.terminal.internal.emulator.VT100EmulatorBackendTest ‑ testNewlineInTopAnchoredScrollRegionCurrentlyDiscardsTopLine
org.eclipse.terminal.internal.emulator.VT100EmulatorBackendTest ‑ testNewlineInTopAnchoredScrollRegionCoveringWholeScreen
org.eclipse.terminal.internal.emulator.VT100EmulatorBackendTest ‑ testNewlineInTopAnchoredScrollRegionMovesTopLineToHistory
org.eclipse.terminal.internal.emulator.VT100EmulatorBackendTest ‑ testNewlineInTopAnchoredScrollRegionWithFullHistoryDropsOldestLine
org.eclipse.terminal.internal.emulator.VT100EmulatorBackendTest ‑ testNewlineInTopAnchoredScrollRegionWithFullHistoryNotifiesScrollToSnapshots

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the feature/terminal-scrollregion-history-2680 branch from e33fdba to 1ebdd3e Compare June 12, 2026 13:14
@stefano-1973

Copy link
Copy Markdown

It seems to work:
image

@vogella
vogella force-pushed the feature/terminal-scrollregion-history-2680 branch from 1ebdd3e to e5b5658 Compare August 4, 2026 17:19
@akurtakov
akurtakov force-pushed the feature/terminal-scrollregion-history-2680 branch from e5b5658 to bf72787 Compare November 4, 2026 19:09
@akurtakov
akurtakov requested a balanced review from Copilot November 4, 2026 19:10

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.

🟡 Changes recommended

When history is full and a footer is present, footer scrolling discards the upward-scroll notification, causing selections to be cleared even though the selected text survives.

1 open issue
What changed in this PR

This PR updates the terminal emulator to preserve scroll-back history for top-anchored scroll regions, addressing the missing backward scrolling reported in #2680.

Changes:

  • Retains displaced top lines in history while keeping footer lines fixed.
  • Updates the characterization test from #2701 and adds coverage for full history and whole-screen regions.
File Description
terminal/​tests/​org.eclipse.terminal.test/​src/​org/​eclipse/​terminal/​internal/​emulator/​VT100EmulatorBackendTest.java Verifies history retention, capacity limits, footer stability, and cursor position.
terminal/​bundles/​org.eclipse.terminal.control/​src/​org/​eclipse/​terminal/​internal/​emulator/​VT100EmulatorBackend.java Routes top-anchored newline scrolling into history and restores footer positioning.

Review effort: Balanced

@akurtakov

akurtakov commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

My test which this PR fixes:
In a terminal in the runtime Eclipse, run clear and then vim -u NONE -N --cmd 'set t_ti= t_te=' /etc/services. The --cmd 'set t_ti= t_te=' keeps Vim off the alternate screen, and it has to be --cmd, because with -c Vim has already switched. Hold j (or press Ctrl-E repeatedly) well past the bottom of the screen, then quit with :q and scroll up. Vim scrolls each line with a scroll region over every row except its status line and a newline at the bottom of that region, so on master those lines are thrown away and the history is empty. With #2764 they go into the history, and you'll see /etc/services from its first line (# /etc/services:) onward, above the prompt.

Full-screen CLIs such as Codex in --no-alt-screen mode, or Vim kept off
the alternate screen, scroll through a DECSTBM region anchored at the top
of the screen. The emulator scrolled such a region in place and dropped
the displaced top line, so no scroll-back history was created.

Like xterm and VTE, a newline at the bottom of such a region now moves
the top line into the history while the lines below the region stay in
place. With a full history the scroll reaches snapshots as one upward
shift, so selections move with the text, and TerminalTextDataFastScroll
rotates its ring buffer and copies back only the fixed lines instead of
the whole history. Regions with a lower top margin still scroll in place.

Fixes the missing scroll-back of
eclipse-platform#2680

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@vogella
vogella force-pushed the feature/terminal-scrollregion-history-2680 branch from bf72787 to 9c5d82b Compare November 6, 2026 08:59
@vogella
vogella requested a balanced review from Copilot November 10, 2026 20:49

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.

🟡 Changes recommended

The scroll optimization leaves stale text in unused ring slots that addLine() later exposes, causing incorrect content when the terminal grows after scrolling.

1 open issue
1 resolved since last review

Review effort: Balanced

@vogella

vogella commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

My test which this PR fixes: In a terminal in the runtime Eclipse, run clear and then vim -u NONE -N --cmd 'set t_ti= t_te=' /etc/services. The --cmd 'set t_ti= t_te=' keeps Vim off the alternate screen, and it has to be --cmd, because with -c Vim has already switched. Hold j (or press Ctrl-E repeatedly) well past the bottom of the screen, then quit with :q and scroll up. Vim scrolls each line with a scroll region over every row except its status line and a newline at the bottom of that region, so on master those lines are thrown away and the history is empty. With #2764 they go into the history, and you'll see /etc/services from its first line (# /etc/services:) onward, above the prompt.

This statement is hard for me to read, but I think this desribes a positive result of testing the PR.

Planning to merge tomorrow, please clarify in case my understanding of the above it not correct.

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.

4 participants