repl: add block-based history navigation#64477
Open
hemanth wants to merge 2 commits into
Open
Conversation
Add experimental REPL enhancements behind the --experimental-repl-enhancements flag: 1. Inline syntax highlighting using the Acorn tokenizer to colorize keywords (magenta), strings (green), numbers (yellow), booleans/null (yellow), regular expressions (red), and comments (gray). 2. Auto-indentation for multiline input based on brace/bracket/paren depth, using 2-space indentation. 3. Function signature hints that display parameter lists as dimmed text below the input when the user types a function call. All features are off by default and require the CLI flag to enable. Highlighting is applied at display time only so cursor positioning and evaluation are unaffected. Refs: nodejs#48164 Signed-off-by: hemanth <hemanth.hm@gmail.com>
Collaborator
|
Review requested:
|
When --experimental-repl-enhancements is enabled, the Up and Down arrow keys now navigate between history entries as whole blocks instead of moving line-by-line within a recalled multiline entry. Previously, recalling a multiline function from history and pressing Up would move the cursor within that entry's lines before advancing to the previous history entry. With this change, Up/Down always jump directly to the previous/next history entry, matching the behavior of Ctrl-P/Ctrl-N. Fixes: nodejs#48146 Signed-off-by: hemanth <hemanth.hm@gmail.com>
ffdbb59 to
35cf0f2
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64477 +/- ##
==========================================
- Coverage 90.23% 90.19% -0.05%
==========================================
Files 741 741
Lines 241375 242181 +806
Branches 45483 45642 +159
==========================================
+ Hits 217800 218427 +627
- Misses 15129 15291 +162
- Partials 8446 8463 +17
🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
When
--experimental-repl-enhancementsis enabled, the Up and Down arrow keys now navigate between history entries as whole blocks instead of moving line-by-line within a recalled multiline entry.Problem
When recalling a multiline function from history and pressing Up, the cursor moves within that entry's lines before advancing to the previous history entry. This makes navigating history with multiline entries tedious — you have to press Up multiple times just to get past a single recalled block.
Solution
With
--experimental-repl-enhancementsenabled, Up/Down always jump directly to the previous/next history entry, matching the behavior of Ctrl-P/Ctrl-N. This makes it easy to recall multiline functions and code blocks with a single keypress.Implementation
kHistoryPrev/kHistoryNextsymbols frominternal/readline/interface_ttyWritehandler when enhancements flag is onkHistoryPrev()/kHistoryNext()directly, bypassing the multiline-move-within-entry logicFixes: #48146