Description
The REPL line editor fails to properly clear the prompt or calculate cursor position when navigating history with Arrow Keys. This results in "ghost" characters (commonly the letter c) being appended or prepended to the input line. This issue is reproducible across glibc (Fedora, NixOS) and musl (Alpine) environments.
Environment
- Engine:
quickjs-ng (version 0.11.0).
- Distros: Fedora, NixOS, Alpine (both
apk and source build).
Steps to Reproduce
- Enter several lines of complex code into the REPL
let b = " hello : 1"
b
console.log(`索引 ${index}: '${char}'`);
[...b].forEach((v, i) => {console.log(`${v} ${i}`)})
console.log(`索引 ${index}: '${char}'`);
console.log(1)
console.log(2)
- Press the Up Arrow key several times to cycle through the history.
- Observe the input line.
Observed Behavior
As you scroll, characters like c (likely remnants of ANSI escape sequences like \x1b[C) begin to leak into the prompt. The line becomes visually corrupted, and the ghost characters do not represent actual code input.