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

otto/repl: autocomplete of chained expressions #342

Open
robfig opened this issue Mar 20, 2019 · 2 comments
Open

otto/repl: autocomplete of chained expressions #342

robfig opened this issue Mar 20, 2019 · 2 comments

Comments

@robfig
Copy link

robfig commented Mar 20, 2019

I noticed that chained expressions do not work with the autocompleter. I was curious if there was any thought on how to support that?

For example, assuming a() returns an object, I would want a().<TAB> to show me that object's properties, but currently the autocompleter shows me globals instead. Looking at the code, I think it would work if lastExpressionRegex changed to select the entire expression. That would result in invoking the function multiple times, but that could be ok..

cc @deoxxa

@Asday
Copy link

Asday commented Mar 20, 2019

Consider the following:

function a() {
  var arr = [ { a: 1, b: 2 }, [ 3, 4, 5 ] ];
  return arr[Math.floor(Math.random() * 2)];
}

Without a strict typing system, autocompletion of chaining is not reliable.

Interestingly, chromium tries to guess, it looks like based on the last invocation of the function:

image

@robfig
Copy link
Author

robfig commented Mar 20, 2019

Yes, that's true, but I think in most cases the type returned is stable, especially without changing the arguments to the function. At any rate, it would do the right thing much more often than the current behavior, which never does the right thing in that scenario?

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

No branches or pull requests

3 participants