Skip to content

Conversation

@hainenber
Copy link

@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
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
Contributor

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
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

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

Labels

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

3 participants