-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
repl: fix tab completion not working with computer string properties #58709
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: fix tab completion not working with computer string properties #58709
Conversation
66a2820
to
9cbd60d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #58709 +/- ##
=======================================
Coverage 90.12% 90.13%
=======================================
Files 637 637
Lines 188121 188121
Branches 36892 36892
=======================================
+ Hits 169552 169568 +16
- Misses 11313 11316 +3
+ Partials 7256 7237 -19
🚀 New features to boost your workflow:
|
9cbd60d
to
3dec780
Compare
3dec780
to
da0d780
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is definitely a nice improvement!
We'd better use acorn to detect these things in the future though. We are for example still missing support for whitespace in-between. We also miss support for partial matches inside of a bracket. That would also be great.
Landed in 0722023 |
I 100% agree, as I mentioned in the PR description this was a first fix I figured I could already land (it also already includes some new tests which will help assuring that changes later work as intended) I'll most likely be using acron on my next iteration here, also I really really want to get rid of this regex: Lines 1228 to 1229 in da0d780
😁 (since it's very complex and not even fully correct)
Can you elaborate? 🙂 |
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
I noticed that the repl tab completion doesn't correctly handle computed properties targeted by strings.
For example given the following context:
The current repl would provide valid (number) completions for lines such as:
But would not provide correct completions for lines such as:
In fact it would provide incorrect (string) completions.
See:

This PR addresses the above issue
Note
This PR is not making everything work perfectly, for example it is not addressing lines such as
obj['o' + 'ne'].to
(but it's not making them any worse either).I think that a generally great solution would require more substantial code changes (potentially with some AST analysis).
I am planning on keeping improving things here but I figured I could do it incrementally and that I'd open this PR to
start moving things in the right direction anyways.