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

node console autocomplete suggestion #6255

Closed
girish3 opened this issue Sep 23, 2013 · 1 comment
Closed

node console autocomplete suggestion #6255

girish3 opened this issue Sep 23, 2013 · 1 comment

Comments

@girish3
Copy link

girish3 commented Sep 23, 2013

After hitting tab, why do I get suggestions(sometimes the same thing twice) when there is only one possible autocomplete suggestion.
for example:-
type 'console.lo' in the node and then hit tab.

@bnoordhuis
Copy link
Member

It's because the auto-completer follows the prototype chain. What that means is this:

> Object.getOwnPropertyNames(console)
[ '_stdout',
  '_stderr',
  '_times',
  'log',
  'info',
  'warn',
  'error',
  'dir',
  'time',
  'timeEnd',
  'trace',
  'assert',
  'Console' ]
> console.__proto__
{ log: [Function],
  info: [Function],
  warn: [Function],
  error: [Function],
  dir: [Function],
  time: [Function],
  timeEnd: [Function],
  trace: [Function],
  assert: [Function] }

Maybe the auto-completer can filter out methods with the same name from higher up in the prototype chain because they're unreachable anyway. Purely filtering on identity won't work though because console.log !== console.__proto__.log.

@TooTallNate Thoughts?

mmalecki added a commit to mmalecki/node that referenced this issue Nov 11, 2013
Fix invalid `hasOwnProperty` function usage.

Fixes nodejs#6255.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants