Only trim prompt (#876)

* Only trim the output for prompts

* Only remove the last newline
This commit is contained in:
JT
2022-01-28 18:22:09 -05:00
committed by GitHub
parent 4c029d2545
commit e91d8655c6
8 changed files with 21 additions and 22 deletions

View File

@ -12,7 +12,6 @@ pub struct RawStream {
pub leftover: Vec<u8>,
pub ctrlc: Option<Arc<AtomicBool>>,
pub is_binary: bool,
pub trim_end: bool,
pub span: Span,
}
@ -20,7 +19,6 @@ impl RawStream {
pub fn new(
stream: Box<dyn Iterator<Item = Result<Vec<u8>, ShellError>> + Send + 'static>,
ctrlc: Option<Arc<AtomicBool>>,
trim_end: bool,
span: Span,
) -> Self {
Self {
@ -28,7 +26,6 @@ impl RawStream {
leftover: vec![],
ctrlc,
is_binary: false,
trim_end,
span,
}
}
@ -46,16 +43,10 @@ impl RawStream {
pub fn into_string(self) -> Result<String, ShellError> {
let mut output = String::new();
let trim_end = self.trim_end;
for item in self {
output.push_str(&item?.as_string()?);
}
if trim_end {
output = output.trim_end().to_string();
}
Ok(output)
}
}