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 tab completion #10

Open
MylesBorins opened this issue Aug 15, 2020 · 3 comments
Open

REPL tab completion #10

MylesBorins opened this issue Aug 15, 2020 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@MylesBorins
Copy link
Member

Tab completion in the REPL would be quite nice

@MylesBorins MylesBorins added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Aug 15, 2020
@shrirambalaji
Copy link

shrirambalaji commented Aug 23, 2020

As a new rustacean 🦀 this issue seems quite interesting to begin with, but I might need some hand-holding 😅

Some initial thoughts on implementing this:

  • Need to use Rustyline's completion API. Played around with it a bit, a completer struct that has the list of annotations for tab completion is probably the way to start off with.

  • The annotations populated are probably of two types, global and contextual, where global annotations are propertyNames of globalThis similar to how we get it on nodejs repl. contextual is the actual tab completion functionality we are looking for though. (not entirely sure about how to go about that). If you probably point me in the right direction and how to go about the implementation, I can try to come up with a PR 😄

Also would like to know, if the goal with jstime's repl is to do things that the nodejs repl does - for eg. .exit, .clear could be simple, yet nice additions imho.

@MylesBorins
Copy link
Member Author

Perhaps starting with the global variable could be a good way to carve out the functionality. TBH I'm not entirely sure how to get the contextual values, perhaps the completion could be updated after each execution of the repl?

As per other functionality like .exit or .clear, totally open to those!

@shrirambalaji
Copy link

shrirambalaji commented Aug 23, 2020

W.r.t globalProps, should we try to use rusty_v8 bindings (or) do script.run_in_scope(scope, Object.getOwnPropertyNames(globalThis)), both of which would work though.

About contextual tab-completion, curious how completion would work after execution, especially when tab-completion for methods / properties on predefined variables, like:

image

Probably a v8 binding call that can be used to list down all the methods / properties that a variable supports? Would have to look into the right v8 calls, based on a variable's type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants