Skip to content

Commit 7eae707

Browse files
zhangyongshengBridgeAR
zhangyongsheng
authored andcommitted
repl: fix bug in fs module autocompletion
PR-URL: #29555 Fixes: #29424 Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent ce45aae commit 7eae707

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ function complete(line, callback) {
11931193
d.name.startsWith(baseName))
11941194
.map((d) => d.name);
11951195
completionGroups.push(filteredValue);
1196-
completeOn = filePath;
1196+
completeOn = baseName;
11971197
} catch {}
11981198
}
11991199

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

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const {
2828
restoreStderr
2929
} = require('../common/hijackstdio');
3030
const assert = require('assert');
31+
const path = require('path');
3132
const fixtures = require('../common/fixtures');
3233
const hasInspector = process.features.inspector;
3334

@@ -434,6 +435,16 @@ testMe.complete('obj.', common.mustCall((error, data) => {
434435
assert.strictEqual(data[0].length, 0);
435436
})
436437
);
438+
439+
const testPath = fixturePath.slice(0, -1);
440+
testMe.complete(testPath, common.mustCall((err, data) => {
441+
assert.strictEqual(err, null);
442+
assert.ok(data[0][0].includes('test-repl-tab-completion'));
443+
assert.strictEqual(
444+
data[1],
445+
path.basename(testPath)
446+
);
447+
}));
437448
});
438449
}
439450
}

0 commit comments

Comments
 (0)