-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Fix repl cursor multiline overflow #60171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Han5991
wants to merge
2
commits into
nodejs:main
Choose a base branch
from
Han5991:fix-repl-cursor-multiline-overflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+107
−6
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,3 +251,71 @@ tmpdir.refresh(); | |
checkResults | ||
); | ||
} | ||
|
||
{ | ||
const historyPath = tmpdir.resolve(`.${Math.floor(Math.random() * 10000)}`); | ||
|
||
// Test for issue #59938: REPL cursor navigation in viewport overflow | ||
// This test just verifies cursor position consistency when input exceeds | ||
// terminal height. The actual screen rendering fix is harder to test | ||
// but can be manually verified. | ||
class MockOutput extends stream.Writable { | ||
constructor() { | ||
super({ | ||
write(chunk, _, next) { | ||
next(); | ||
} | ||
}); | ||
this.columns = 80; | ||
this.rows = 20; | ||
} | ||
} | ||
|
||
const checkResults = common.mustSucceed((r) => { | ||
r.write('const arr = ['); | ||
r.input.run([{ name: 'enter' }]); | ||
|
||
for (let i = 1; i <= 25; i++) { | ||
r.write(` ${i},`); | ||
r.input.run([{ name: 'enter' }]); | ||
} | ||
|
||
r.write('];'); | ||
|
||
const endCursor = r.cursor; | ||
assert.ok(endCursor > 0); | ||
|
||
for (let i = 0; i < 27; i++) { | ||
r.input.run([{ name: 'up' }]); | ||
} | ||
|
||
assert.strictEqual(r.cursor, 0); | ||
|
||
const prevRowsAtTop = r.prevRows; | ||
assert.ok(prevRowsAtTop !== undefined); | ||
|
||
for (let i = 0; i < 10; i++) { | ||
r.input.run([{ name: 'down' }]); | ||
} | ||
|
||
const midCursor = r.cursor; | ||
assert.ok(midCursor > 0 && midCursor < endCursor); | ||
|
||
// Navigate back to end | ||
for (let i = 0; i < 17; i++) { | ||
r.input.run([{ name: 'down' }]); | ||
} | ||
|
||
assert.strictEqual(r.cursor, endCursor); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what are we testing here. As I see, the cursor position always updated, but it's the visible content which did not. |
||
}); | ||
|
||
repl.createInternalRepl( | ||
{ NODE_REPL_HISTORY: historyPath }, | ||
{ | ||
terminal: true, | ||
input: new ActionStream(), | ||
output: new MockOutput(), | ||
}, | ||
checkResults | ||
); | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only show the prompt on the actual first line of the content. Not the first line of the visible content.