Skip to content

repl: add auto-indentation for multiline input - #64607

Open
hemanth wants to merge 1 commit into
nodejs:mainfrom
hemanth:repl/auto-indent
Open

repl: add auto-indentation for multiline input#64607
hemanth wants to merge 1 commit into
nodejs:mainfrom
hemanth:repl/auto-indent

Conversation

@hemanth

Copy link
Copy Markdown
Contributor

Split from #64443 per review feedback to use idiomatic single-feature PRs.

Automatically inserts 2-space indentation on continuation lines based on the current nesting depth of braces, brackets, and parentheses.

Refs: #48164

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. labels Jul 19, 2026
Comment threadlib/repl.js Outdated
Comment threadlib/internal/repl/utils.js Outdated
Comment threadlib/internal/repl/utils.js Outdated
@hemanth

hemanth commented Jul 19, 2026

Copy link
Copy Markdown
ContributorAuthor
  • setupAutoIndent → standalone getAutoIndent(code) helper, no more monkey-patching the REPL instance
  • Dropped the typeof guard — direct call since the helper is always available
  • Swapped manual char scanner for Acorn tokenizer (same one used in isRecoverableError), falls back to simple brace-counting on parse failure

PTAL @avivkeller

Comment threadlib/internal/repl/utils.js Outdated
Comment threadlib/internal/repl/utils.js Outdated
@hemanth

Copy link
Copy Markdown
ContributorAuthor

Good call — dropped the Acorn re-parse entirely. isRecoverableError already validates syntax before getAutoIndent runs, so a simple brace counter is sufficient here. Lighter and no duplicate work 👍

PTAL @avivkeller

Automatically insert 2-space indentation on continuation lines
based on brace/bracket/paren depth when entering multiline input.
Refs: nodejs#48164
Signed-off-by: hemanth <hemanth.hm@gmail.com>
@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.12%. Comparing base (0bcc6ef) to head (aa16617).
⚠️ Report is 119 commits behind head on main.

Files with missing linesPatch %Lines
lib/internal/repl/utils.js98.07%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64607 +/- ##
==========================================
- Coverage 90.14% 90.12% -0.02% 
==========================================
Files 741 741 Lines 242080 242140 +60 Branches 45563 45575 +12 ==========================================
+ Hits 218213 218239 +26 - Misses 15375 15425 +50 + Partials 8492 8476 -16 
Files with missing linesCoverage Δ
lib/repl.js92.96% <100.00%> (+0.04%)⬆️
lib/internal/repl/utils.js96.99% <98.07%> (+0.06%)⬆️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ciPRs that need a full CI run.replIssues and PRs related to the REPL subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@hemanth@avivkeller@nodejs-github-bot