diff --git a/module-request-ai/src/buffer.rs b/module-request-ai/src/buffer.rs index 8150f28..99556b6 100644 --- a/module-request-ai/src/buffer.rs +++ b/module-request-ai/src/buffer.rs @@ -101,37 +101,34 @@ impl Buffer { let buffered = self.buf.join("").trim().to_string(); self.buf.clear(); if buffered.ends_with("") { - let warn = format!("\r{}:", t!("ai-suggestion")) + let warn = format!("{}:", t!("ai-suggestion")) .bold() .blue() .to_string(); let first = buffered.replace("", &warn); - eprintln!("{}", first); + eprintln!("\r{}", first); std::io::stdout().flush().unwrap(); } else if buffered.ends_with("") { let tag = ""; let whitespace = " ".repeat(tag.len()); - let formatted = format!("\r{}", whitespace); - let first = buffered.replace("", &formatted); - eprintln!("{}", first); + let clear = whitespace.to_string(); + let first = buffered.replace("", &clear); + eprintln!("\r{}", first); self.state = State::Buf; std::io::stdout().flush().unwrap(); } else if buffered.ends_with("") { let tag = ""; - let warn = format!("\r{}:", t!("ai-thinking")) - .bold() - .blue() - .to_string(); + let warn = format!("{}:", t!("ai-thinking")).bold().blue().to_string(); let first = buffered.replace(tag, &warn); self.state = State::Think; - eprintln!("{}", first); + eprintln!("\r{}", first); std::io::stdout().flush().unwrap(); } else if buffered.ends_with("") { let tag = ""; let whitespace = " ".repeat(tag.len()); - let formatted = format!("\r{}", whitespace); - let first = buffered.replace(tag, &formatted); - eprintln!("{}", first); + let clear = whitespace.to_string(); + let first = buffered.replace(tag, &clear); + eprintln!("\r{}", first); std::io::stdout().flush().unwrap(); } else if buffered.ends_with("```") { let tag = "```"; @@ -179,10 +176,10 @@ impl Buffer { if buffered.ends_with("") { let tag = ""; let whitespace = " ".repeat(tag.len()); - let formatted = format!("\r{}", whitespace); - let first = buffered.replace(tag, &formatted); + let clear = whitespace.to_string(); + let first = buffered.replace(tag, &clear); self.state = State::Write; - eprintln!("{}", first); + eprintln!("\r{}", first); std::io::stdout().flush().unwrap(); } else { eprintln!("{}", first);