Skip to content

Commit

Permalink
repl: fix bug in fs module autocompletion
Browse files Browse the repository at this point in the history
PR-URL: #29555
Fixes: #29424
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
zhangyongsheng authored and BridgeAR committed Sep 25, 2019
1 parent ce45aae commit 7eae707
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ function complete(line, callback) {
d.name.startsWith(baseName))
.map((d) => d.name);
completionGroups.push(filteredValue);
completeOn = filePath;
completeOn = baseName;
} catch {}
}

Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-repl-tab-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const {
restoreStderr
} = require('../common/hijackstdio');
const assert = require('assert');
const path = require('path');
const fixtures = require('../common/fixtures');
const hasInspector = process.features.inspector;

Expand Down Expand Up @@ -434,6 +435,16 @@ testMe.complete('obj.', common.mustCall((error, data) => {
assert.strictEqual(data[0].length, 0);
})
);

const testPath = fixturePath.slice(0, -1);
testMe.complete(testPath, common.mustCall((err, data) => {
assert.strictEqual(err, null);
assert.ok(data[0][0].includes('test-repl-tab-completion'));
assert.strictEqual(
data[1],
path.basename(testPath)
);
}));
});
}
}
Expand Down

0 comments on commit 7eae707

Please sign in to comment.