GeezerVison is showing github.com — repl: make own properties shadow prototype properties · nodejs/node@4b613d3
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/repl.js +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1229,20 +1229,20 @@ function complete(line, callback) { | 1229 | 1229 | // Completion group 0 is the "closest" | 1230 | 1230 | // (least far up the inheritance chain) | 1231 | 1231 | // 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++) { | 1233 | 1233 | group = completionGroups[i]; | 1234 | 1234 | group.sort(); | 1235 | | - for (var j = 0; j < group.length; j++) { | | 1235 | + for (var j = group.length - 1; j >= 0; j--) { | 1236 | 1236 | c = group[j]; | 1237 | 1237 | if (!hasOwnProperty(uniq, c)) { | 1238 | | - completions.push(c); | | 1238 | + completions.unshift(c); | 1239 | 1239 | uniq[c] = true; | 1240 | 1240 | } | 1241 | 1241 | } | 1242 | | - completions.push(''); // Separator btwn groups | | 1242 | + completions.unshift(''); // Separator btwn groups | 1243 | 1243 | } | 1244 | | - while (completions.length && completions[completions.length - 1] === '') { | 1245 | | - completions.pop(); | | 1244 | + while (completions.length && completions[0] === '') { | | 1245 | + completions.shift(); | 1246 | 1246 | } | 1247 | 1247 | } | 1248 | 1248 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-repl-tab-complete.js +18-1Lines changed: 18 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -149,7 +149,10 @@ putIn.run([ | 149 | 149 | ' one:1', | 150 | 150 | '};' | 151 | 151 | ]); | 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 | +})); | 153 | 156 |
| 154 | 157 | putIn.run(['.clear']); | 155 | 158 |
| @@ -206,6 +209,20 @@ testMe.complete('toSt', common.mustCall(function(error, data) { | 206 | 209 | assert.deepStrictEqual(data, [['toString'], 'toSt']); | 207 | 210 | })); | 208 | 211 |
| | 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 | + | 209 | 226 | // Tab complete provides built in libs for require() | 210 | 227 | putIn.run(['.clear']); | 211 | 228 |
| |
|