Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

REPL: tab complete for Arrays #25819

Closed
wants to merge 1 commit into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Aug 6, 2015

Slight modified version of @seebees original commit:

seebees@d624a68

The original message:
The tab complete for Arrays will
include any integer indexes. This is
suboptimal because obj.21 is not
valid syntax and a large array will
contain a very cluttered list.

This alternative tweaks the original commit to use
Array.isArray and isNaN for the filter. Everything
else in untouched.

Slight modified version of @seebees original commit:

seebees@d624a68

The original message:
  The tab complete for Arrays will
  include any integer indexes.  This is
  suboptimal because obj.21 is not
  valid syntax and a large array will
  contain a very cluttered list.

This alternative tweaks the original commit to use
Array.isArray and isNaN for the filter. Everything
else in untouched.
@jasnell
Copy link
Member Author

jasnell commented Aug 6, 2015

@joyent/node-tsc .. quick review?

.push(Object
.getOwnPropertyNames(obj)
.filter(function(item) {
return isNaN(parseInt(item));
Copy link

Choose a reason for hiding this comment

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

Maybe use +item instead of parseInt(). For example, parseInt('3c') returns 3.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's actually a 'feature' ;-) ... consider.. var m = []; m['123abc'] = 'a' .. if you do tab completion, the 123abc and use +item, the 123abc would still appear, which ends up having the same problem this patch is trying to fix. Using parseInt filters those out, even if they are valid keys for the object.

Copy link

Choose a reason for hiding this comment

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

Ah, carry on then :-)

@seebees
Copy link

seebees commented Aug 6, 2015

@jasnell How cool is that! thanks! What's the best way to get a PR reviewed?

@jasnell
Copy link
Member Author

jasnell commented Aug 6, 2015

In an ideal world, all PR's will be reviewed ;-) ... some just may take longer than others. This particular one is being actively reviewed now. Barring any issues, it should land shortly.

'asdf.hasOwnProperty', 'asdf.isPrototypeOf',
'asdf.propertyIsEnumerable',
'asdf.toLocaleString', 'asdf.toString',
'asdf.valueOf', '', 'asdf.1'],

Choose a reason for hiding this comment

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

Hmmm asdf.1 is still invalid

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking into the test... it appears that somewhere along the line, test-repl-tab-complete stopped working properly. The entire test is not run and exits with a success without executing all of the code. Investigating now

Copy link

Choose a reason for hiding this comment

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

The issue with the test exiting part of the way through has been fixed in the converged repo.

@jasnell
Copy link
Member Author

jasnell commented Aug 16, 2015

Will be updating this shortly...

@jasnell
Copy link
Member Author

jasnell commented Aug 17, 2015

Closing here in favor of nodejs/node#2409, which is a more complete approach. That will need to be cherry picked back to v0.12 and v0.10 at some point

@jasnell jasnell closed this Aug 17, 2015
jasnell added a commit to jasnell/node that referenced this pull request Aug 22, 2015
Refactored version of nodejs/node-v0.x-archive#25819

Removes integer keys (and keys starting with numbers) from
candidate list on repl tab complete. Refactored the originally
submitted change to simplify and ensure that the integer keys
do not show up on objects either.
jasnell added a commit to nodejs/node that referenced this pull request Aug 22, 2015
Refactored version of nodejs/node-v0.x-archive#25819

Removes integer keys (and keys starting with numbers) from
candidate list on repl tab complete. Refactored the originally
submitted change to simplify and ensure that the integer keys
do not show up on objects either.

Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: #2409
jasnell added a commit to nodejs/node that referenced this pull request Aug 22, 2015
Refactored version of nodejs/node-v0.x-archive#25819

Removes integer keys (and keys starting with numbers) from
candidate list on repl tab complete. Refactored the originally
submitted change to simplify and ensure that the integer keys
do not show up on objects either.

Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: #2409
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants