reedline icon indicating copy to clipboard operation
reedline copied to clipboard

bug: displays ghost characters after deletion in RustRover terminal

Open mon3stera opened this issue 7 months ago • 4 comments

Platform: Arch Linux x86_64

Terminal software: RustRover IDE built-in terminal

Problem Description

When using the Reedline library with a custom multiline prompt in RustRover's built-in terminal, "ghost characters" appear after deleting characters. These characters appear in gray, behaving as if the deleted characters still exist, although they have been removed from the internal text buffer.

This issue is terminal-specific - it occurs in RustRover terminal (which uses TERM=xterm-256color) but does not occur in Kitty terminal (which uses TERM=xterm-kitty). The problem is also specific to multiline prompts - it doesn't happen when using DefaultPrompt (single-line prompt).

Steps to Reproduce

  1. Use RustRover IDE (2024.3.7 or 2025.1.2) on Linux (or any other JetBrains IDE terminal using xterm-256color)
  2. Implement a custom Prompt with multiline rendering (containing newline character \n)
  3. Type several consecutive characters (e.g., "dddddd")
  4. Delete some characters using backspace (e.g., delete two "dd")
  5. Observe: The deleted characters are still visible as gray "ghost characters" despite being removed from the internal text buffer
ddd|ddddd
    ~~~~~
       deleted but visible

Image

The minimal code :

impl Prompt for TestPrompt {
    fn render_prompt_left(&self) -> Cow<str> {
        Cow::Owned(String::from("\n"))
    }

    fn render_prompt_right(&self) -> Cow<str> {
        Cow::Owned(String::new())
    }

    fn render_prompt_indicator(&self, prompt_mode: PromptEditMode) -> Cow<str> {
        Cow::Owned(String::new())
    }

    fn render_prompt_multiline_indicator(&self) -> Cow<str> {
        Cow::Owned(String::new())
    }

    fn render_prompt_history_search_indicator(&self, history_search: PromptHistorySearch) -> Cow<str> {
        Cow::Owned(String::new())
    }
}

// main.rs
fn main() {
	let prompt = TestPrompt::default();
 	let mut reedline = Reedline::create();
 
 	reedline.read_line(&prompt).unwrap();
}

Problem Verification

Switching to DefaultPrompt (single-line prompt) makes the issue disappear, indicating the problem is related to the multiline prompt rendering.

Technical Details

  • Reedline version: 0.40.0
  • Terminal comparison:
    • Issue present: RustRover built-in terminal (TERM=xterm-256color)
    • Working correctly: Kitty terminal (TERM=xterm-kitty)
  • Reproduction rate: 100% (occurs every time characters are deleted)

Suspected Cause

The issue might be related to the buffer redraw mechanism in Reedline when handling multiline prompts. When processing delete operations, the buffer might not completely clear previously displayed content, especially when using multiline prompts and specific terminal types. This could involve issues with ANSI control sequence handling or cursor position calculation.

Temporary Workaround

As a temporary solution, the issue can be resolved using one of the following methods:

  1. Use a single-line prompt instead of a multiline prompt
  2. Use another terminal like Kitty

mon3stera avatar May 20 '25 05:05 mon3stera

Sounds like maybe you're experiencing the hint system in reedline. Kind of like I'm typing $env here and the hint is showing a similar command.

Image

You can also see that I'm using a multiline prompt in nushell.

I'm not sure how/why this would change between terminals though. Hints show up in kitty for me but the colors are a little different.

Image

fdncred avatar May 20 '25 11:05 fdncred

Initially I also thought it was caused by the hinter, but I experience the same issue even when just using Reedline::create() without configuring any hinter. However, since it works normally in kitty, it's not that big of a problem.

mon3stera avatar May 20 '25 14:05 mon3stera

Very weird. Not sure what's going on if it's not the hinter.

fdncred avatar May 20 '25 17:05 fdncred

I wonder if it's related to the recent Terminal rework: https://blog.jetbrains.com/idea/2025/04/jetbrains-terminal-a-new-architecture/

Maybe try changing the terminal engine to see what happens?

null-dev avatar Jun 18 '25 10:06 null-dev