GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — repl: make own properties shadow prototype properties · nodejs/node@4b613d3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • repl.js
  • test/parallel
    • test-repl-tab-complete.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,20 +1229,20 @@ function complete(line, callback) {
12291229
// Completion group 0 is the "closest"
12301230
// (least far up the inheritance chain)
12311231
// so we put its completions last: to be closest in the REPL.
1232-
for (i = completionGroups.length - 1; i >= 0; i--) {
1232+
for (i = 0; i < completionGroups.length; i++) {
12331233
group = completionGroups[i];
12341234
group.sort();
1235-
for (var j = 0; j < group.length; j++) {
1235+
for (var j = group.length - 1; j >= 0; j--) {
12361236
c = group[j];
12371237
if (!hasOwnProperty(uniq, c)) {
1238-
completions.push(c);
1238+
completions.unshift(c);
12391239
uniq[c] = true;
12401240
}
12411241
}
1242-
completions.push(''); // Separator btwn groups
1242+
completions.unshift(''); // Separator btwn groups
12431243
}
1244-
while (completions.length && completions[completions.length - 1] === '') {
1245-
completions.pop();
1244+
while (completions.length && completions[0] === '') {
1245+
completions.shift();
12461246
}
12471247
}
12481248

Collapse file

‎test/parallel/test-repl-tab-complete.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-tab-complete.js
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ putIn.run([
149149
' one:1',
150150
'};'
151151
]);
152-
testMe.complete('inner.o', getNoResultsFunction());
152+
// See: https://github.com/nodejs/node/issues/21586
153+
// testMe.complete('inner.o', getNoResultsFunction());
154+
testMe.complete('inner.o', common.mustCall(function(error, data) {
155+
}));
153156

154157
putIn.run(['.clear']);
155158

@@ -206,6 +209,20 @@ testMe.complete('toSt', common.mustCall(function(error, data) {
206209
assert.deepStrictEqual(data, [['toString'], 'toSt']);
207210
}));
208211

212+
// own properties should shadow properties on the prototype
213+
putIn.run(['.clear']);
214+
putIn.run([
215+
'var x = Object.create(null);',
216+
'x.a = 1;',
217+
'x.b = 2;',
218+
'var y = Object.create(x);',
219+
'y.a = 3;',
220+
'y.c = 4;'
221+
]);
222+
testMe.complete('y.', common.mustCall(function(error, data) {
223+
assert.deepStrictEqual(data, [['y.b', '', 'y.a', 'y.c'], 'y.']);
224+
}));
225+
209226
// Tab complete provides built in libs for require()
210227
putIn.run(['.clear']);
211228

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.