Using yansi for coloring everything works perfectly except when I try to color the prompt, in that case it puts blanks as in this image (and does weird things when you delete characters):

To reproduce it we create a new project adding the dependencies:
cargo new myfancytest
cd myfancytest
cargo add rustyline
cargo add yansi
And we use the same code of the readme example but coloring the prompt with yansi:
use yansi::Paint;
use rustyline::error::ReadlineError;
use rustyline::{DefaultEditor, Result};
fn main() -> Result<()> {
// `()` can be used when no completer is required
let mut rl = DefaultEditor::new()?;
#[cfg(feature = "with-file-history")]
if rl.load_history("history.txt").is_err() {
println!("No previous history.");
}
loop {
let readline = rl.readline(&format!("{} ", ">>".yellow()));
match readline {
Ok(line) => {
rl.add_history_entry(line.as_str());
println!("Line: {}", line);
},
Err(ReadlineError::Interrupted) => {
println!("CTRL-C");
break
},
Err(ReadlineError::Eof) => {
println!("CTRL-D");
break
},
Err(err) => {
println!("Error: {:?}", err);
break
}
}
}
#[cfg(feature = "with-file-history")]
rl.save_history("history.txt");
Ok(())
}
Using yansi for coloring everything works perfectly except when I try to color the prompt, in that case it puts blanks as in this image (and does weird things when you delete characters):

To reproduce it we create a new project adding the dependencies:
And we use the same code of the readme example but coloring the prompt with
yansi: