Skip to content
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

[repl] do not show all matches on first tab #7665

Closed
trevnorris opened this issue Jul 11, 2016 · 11 comments
Closed

[repl] do not show all matches on first tab #7665

trevnorris opened this issue Jul 11, 2016 · 11 comments
Labels
feature request Issues that request new features to be added to Node.js. readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem.

Comments

@trevnorris
Copy link
Contributor

  • Version: All
  • Platform: All
  • Subsystem: REPL (shipped)

It's an annoyance that the REPL prints out all possibilities the first time hitting the tab. It would be much better if it simply autocompleted as much as possible and waited for a subsequent tab before printing out all matches. Here's an example usages:

> Bu<TAB>.al<TAB>U<TAB>S<TAB>

To produce Buffer.allocUnsafeSlow, but in doing so I get a screen filled with matches that I know I don't want.

Throwing this out there in case anyone wants to take care of it before I do (which I don't plan to in the near future).

@trevnorris trevnorris added the repl Issues and PRs related to the REPL subsystem. label Jul 11, 2016
@mscdex mscdex added the feature request Issues that request new features to be added to Node.js. label Jul 12, 2016
@princejwesley
Copy link
Contributor

princejwesley commented Jul 12, 2016

@mscdex @trevnorris FYI, Its implemented for .editor mode (PR link). If .editor mode is good to go, I'll update PR to support least common prefix based tab completion for default mode.

@Fishrock123
Copy link
Contributor

We should do this with or without .editor support.

@princejwesley
Copy link
Contributor

yes, since editor mode PR has support for LCP Tab completion, I thought of modify it to support for all cases.

@silverwind
Copy link
Contributor

Would very much like this feature. We can probably re-use some code, because this works:

> require('a<TAB>
> require('assert

@trevnorris
Copy link
Contributor Author

Ooh. How about automatic path searching? e.g. require('./foo<TAB> :)

@silverwind
Copy link
Contributor

silverwind commented Jul 12, 2016

How about automatic path searching?

Already kind of works, but it wrongly expands require('./<TAB> to stuff inside node_modules.

Oh, and adding to the wishlist for tab-completion, require('path').<TAB> could suggest all return properties from that function call.

@addaleax
Copy link
Member

Oh, and adding to the wishlist for tab-completion, require('path').<TAB> could suggest all return properties from that function call.

That would be awesome, but these kind of things get really tricky, as require()ing a module can have side effects and tab completion never should have any.

@silverwind
Copy link
Contributor

side effects

True, probably not worth the risk and hassle to implement something timeout-based.

@princejwesley
Copy link
Contributor

Incorporated tab completion support in #7275

@addaleax addaleax added the readline Issues and PRs related to the built-in readline module. label Jul 15, 2016
@addaleax
Copy link
Member

PR for solving this on the readline level: #7754

addaleax added a commit to addaleax/node that referenced this issue Aug 2, 2016

Verified

This commit was signed with the committer’s verified signature.
Cogax Cogax
Show `TAB` completion suggestions only after the user has pressed `TAB`
twice in a row, so that the full list of suggestions doesn’t present
a distraction. The first time a `TAB` key is pressed, only partial
longest-common-prefix completion is performed.

This moves the `readline` autocompletion a lot closer to what e.g.
`bash` does.

Fixes: nodejs#7665
@trevnorris
Copy link
Contributor Author

Whoot! Thanks @addaleax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants