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

feat(cli/repl) add tab completion #7827

Merged
merged 36 commits into from
Oct 19, 2020

Conversation

caspervonb
Copy link
Contributor

@caspervonb caspervonb commented Oct 5, 2020

This adds tab completion for global identifiers and object properties.

Closes #3086

loop {
for (method, params) in message_rx.try_iter() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make this a stream and select on it below.

@bartlomieju bartlomieju added this to the 1.5.0 milestone Oct 7, 2020
@caspervonb
Copy link
Contributor Author

caspervonb commented Oct 7, 2020

Alright so right the first pass only supports a few simple scenarios single line scenarios

Deno.|<tab>
Deno.write|<tab>
Deno[|<tab>
Deno["write|<tab>

Next step would be for completions for multi-line "lines" based on the current cursor position

const foo = Deno.|<tab>
(
  Deno.write<tab>
)
false, Deno[<tab>
true && Deno["write<tab>

And also add support for identifier completions

De|<tab>
let foo = win|<tab>
(
  con|<tab>
)

@ry
Copy link
Member

ry commented Oct 7, 2020

Tested it locally - seems to work! Very nice.

It only works for Deno.|<tab> tho. When I do windo|<tab> it doesn't complete to "window".

@caspervonb
Copy link
Contributor Author

. When I do windo| it doesn't complete to "window".

Yet to be implemented, only the rhs of propery accessors are completed at the moment 🙃

@caspervonb

This comment has been minimized.

@caspervonb caspervonb marked this pull request as ready for review October 17, 2020 13:33
@bartlomieju
Copy link
Member

@caspervonb please rebase

@caspervonb
Copy link
Contributor Author

caspervonb commented Oct 19, 2020

Will do, merge #7896 before this one please (it's freshly rebased) 🙃

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, very cool feature 🚀

In future we should consider changing colors a bit for autocompleted items or even displaying list of all possible suggestions.

@bartlomieju bartlomieju merged commit c488468 into denoland:master Oct 19, 2020
@caspervonb
Copy link
Contributor Author

caspervonb commented Oct 19, 2020

There are other completion modes available, specifically there's a list list-mode that interoperates with "hints" (the one trait we haven't touched on yet in rustyline).

So yeah that's open ended and should be relatively accessible for tweaking 🎉 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tab completion in REPL
4 participants