Fix repl cursor multiline overflow #60171
Open
+107
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #59938
When multiline REPL input exceeds the terminal height, navigating the cursor with arrow
keys would move the cursor position correctly but fail to refresh the screen properly,
leaving stale content visible on the screen.
Problem
In the REPL, when a multiline input has more lines than the terminal height:
Solution
This PR implements viewport-based rendering in
kRefreshLine()
that displays only thevisible portion of input centered around the cursor position when content exceeds
terminal height:
Changes
rows
getter toInterface
class for terminal height detectionMathMin
primitive for viewport calculationskRefreshLine()
to calculate visible line range based on:this.rows
)prevRows
calculation to account for viewport positionDemo
Before (Bug):
[Your video showing the bug - cursor moves but screen doesn't refresh]
After (Fixed):
[Your video showing the fix - screen properly refreshes during navigation]
Testing
2025-10-09.10.55.16.mov
Added regression test in
test/parallel/test-repl-multiline-navigation.js
that:Run tests: