Skip to content

Conversation

@hainenber
Copy link
Contributor

@hainenber hainenber commented Oct 19, 2025

Summary

Fixes #60306

I've modified the function findExpressionCompleteTarget to handle autocompletion for new <class> code by detecting proper identifiers and re-parse only for <class> identifier instead.

Testing

  • New test added: test/parallel/test-repl-tab-complete-new-expression.js
  • Visual confirmation with expected correct behavior in linked issue
image

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. labels Oct 19, 2025
@hainenber
Copy link
Contributor Author

hi @Renegade334, sorry for pinging but can you help review this one? I hope everything's up to par with expected quality for a nodejs/node pull request

// we want to extract the callee for completion (e.g. for `new Sample` we want `Sample`)
if (lastBodyStatement.type === 'ExpressionStatement' &&
lastBodyStatement.expression.type === 'NewExpression' &&
lastBodyStatement.expression.callee.type === 'Identifier') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check necessary? It excludes MemberExpressions (the same logic should apply to new X.Y. as applies to new X.).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I've loosened the condition to only null check the expression.callee properties. This should handle case of new X.Y..

Please take a look when you have time.

image

@BridgeAR BridgeAR added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 4, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 4, 2025
@nodejs-github-bot
Copy link
Collaborator

@BridgeAR BridgeAR added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 5, 2025
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.53%. Comparing base (e105e82) to head (3549c25).
⚠️ Report is 336 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #60319    +/-   ##
========================================
  Coverage   88.53%   88.53%            
========================================
  Files         704      703     -1     
  Lines      208087   208270   +183     
  Branches    40006    40158   +152     
========================================
+ Hits       184223   184391   +168     
- Misses      15869    15885    +16     
+ Partials     7995     7994     -1     
Files with missing lines Coverage Δ
lib/internal/repl/completion.js 94.82% <100.00%> (+0.06%) ⬆️

... and 206 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.

@Renegade334
Copy link
Member

CI is complaining that you have a double-space in your first commit message, can you please amend this?

@hainenber hainenber force-pushed the fix/repl-autocompletion-for-new-operator branch from 39c7534 to bfeae87 Compare November 18, 2025 15:05
@hainenber
Copy link
Contributor Author

CI is complaining that you have a double-space in your first commit message, can you please amend this?

I've fixed in the HEAD commit. Apologies for the force push, I had to rebase and pick reword.

Signed-off-by: hainenber <dotronghai96@gmail.com>
Signed-off-by: hainenber <dotronghai96@gmail.com>
@hainenber hainenber force-pushed the fix/repl-autocompletion-for-new-operator branch from bfeae87 to 3549c25 Compare November 18, 2025 15:11
@Renegade334 Renegade334 added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 20, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 20, 2025
@nodejs-github-bot
Copy link
Collaborator

@Renegade334 Renegade334 added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 20, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 20, 2025
@nodejs-github-bot nodejs-github-bot merged commit d729bec into nodejs:main Nov 20, 2025
68 of 71 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in d729bec

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

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repl: autocompletion after new X. targets new X(), not X

4 participants