fix(readline): use symbol key for _refreshLine in tab completer (#26412)

This commit is contained in:
robobun
2026-01-24 15:37:29 -08:00
committed by GitHub
parent ab3df344b8
commit 70fe76209b
2 changed files with 41 additions and 1 deletions

View File

@@ -1534,7 +1534,7 @@ var _Interface = class Interface extends InterfaceConstructor {
prefix +
StringPrototypeSlice.$call(this.line, this.cursor, this.line.length);
this.cursor = this.cursor - completeOn.length + prefix.length;
this._refreshLine();
this[kRefreshLine]();
return;
}

View File

@@ -0,0 +1,40 @@
import { expect, test } from "bun:test";
import { bunEnv, bunExe } from "harness";
// https://github.com/oven-sh/bun/issues/26411
// Tab completion with node:readline/promises threw
// "TypeError: this._refreshLine is not a function"
test("tab completion works with node:readline/promises", async () => {
await using proc = Bun.spawn({
cmd: [
bunExe(),
"-e",
`
import readline from "node:readline/promises";
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: true,
completer: (line) => [["FOO", "FOOBAR"], line]
});
rl.line = "foo";
rl.cursor = 3;
setTimeout(() => {
rl.close();
console.log("OK");
process.exit(0);
}, 100);
rl.write("", { name: "tab" });
`,
],
env: bunEnv,
stdout: "pipe",
stderr: "pipe",
});
const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]);
expect(stderr).not.toContain("this._refreshLine is not a function");
expect(stdout).toContain("OK");
expect(exitCode).toBe(0);
});