Skip to content

Commit

Permalink
Don't remove color from prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Orru committed Jun 20, 2020
1 parent c2c8e40 commit f31d7fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use crate::validate::{ValidationContext, ValidationResult};
/// Implement rendering.
pub struct State<'out, 'prompt, H: Helper> {
pub out: &'out mut <Terminal as Term>::Writer,
prompt: &'prompt str, // Prompt to display (rl_prompt)
prompt_size: Position, // Prompt Unicode/visible width and height
pub line: LineBuffer, // Edited line buffer
pub prompt: &'prompt str, // Prompt to display (rl_prompt)
pub prompt_size: Position, // Prompt Unicode/visible width and height
pub line: LineBuffer, // Edited line buffer
pub layout: Layout,
saved_line_for_history: LineBuffer, // Current edited line before history browsing
byte_buffer: [u8; 4],
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ fn complete_hint_line<H: Helper>(s: &mut State<'_, '_, H>) -> Result<()> {
if s.line.yank(hint, 1).is_none() {
s.out.beep()?;
}
s.line.buf = String::from_utf8(strip_ansi_escapes::strip(s.line.buf.clone()).unwrap()).unwrap();

let prompt = s.prompt.to_string();
let command =
String::from_utf8(strip_ansi_escapes::strip(&s.line.buf[prompt.len()..]).unwrap()).unwrap();
s.line.buf = format!("{}{}", prompt, command);

s.refresh_line_with_msg(None)?;
Ok(())
}
Expand Down

0 comments on commit f31d7fc

Please sign in to comment.