diff options
author | Sam Ruby <rubys@intertwingly.net> | 2018-06-29 12:49:36 -0400 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-07-13 18:57:16 +0200 |
commit | 4d42083d1a2a5632589e79aa3b780a7d7c93a2e1 (patch) | |
tree | 85873beed4168053f20e97a084a687d75413bfa4 /lib/repl.js | |
parent | 949e8851484c016c07f6cc9e5889f0f2e56baf2a (diff) | |
download | android-node-v8-4d42083d1a2a5632589e79aa3b780a7d7c93a2e1.tar.gz android-node-v8-4d42083d1a2a5632589e79aa3b780a7d7c93a2e1.tar.bz2 android-node-v8-4d42083d1a2a5632589e79aa3b780a7d7c93a2e1.zip |
repl: make own properties shadow prototype properties
Previously, the code displayed properties backwards (e.g., showing
prototype properties before own properties). It also did uniqueness
checks during this processing, so these checks were done backwards.
After this change, the properties continue to be displayed backwards,
but the uniqueness checks are done in the proper order.
See also: https://github.com/nodejs/node/issues/21586 which was
discovered during the testing of this fix.
Fixes: https://github.com/nodejs/node/issues/15199
PR-URL: https://github.com/nodejs/node/pull/21588
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/repl.js')
-rw-r--r-- | lib/repl.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/repl.js b/lib/repl.js index 6345c742f6..92c90de7bb 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1229,20 +1229,20 @@ function complete(line, callback) { // Completion group 0 is the "closest" // (least far up the inheritance chain) // so we put its completions last: to be closest in the REPL. - for (i = completionGroups.length - 1; i >= 0; i--) { + for (i = 0; i < completionGroups.length; i++) { group = completionGroups[i]; group.sort(); - for (var j = 0; j < group.length; j++) { + for (var j = group.length - 1; j >= 0; j--) { c = group[j]; if (!hasOwnProperty(uniq, c)) { - completions.push(c); + completions.unshift(c); uniq[c] = true; } } - completions.push(''); // Separator btwn groups + completions.unshift(''); // Separator btwn groups } - while (completions.length && completions[completions.length - 1] === '') { - completions.pop(); + while (completions.length && completions[0] === '') { + completions.shift(); } } |