Skip to content

REPL History Ghosting: Spurious characters (e.g., 'c') appear when cycling through history via Arrow keys #1325

@JadeYao-z

Description

@JadeYao-z

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

  1. 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)
  1. Press the Up Arrow key several times to cycle through the history.
  2. Observe the input line.
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions