mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Only trim prompt (#876)
* Only trim the output for prompts * Only remove the last newline
This commit is contained in:
@ -124,7 +124,6 @@ impl Command for Open {
|
||||
RawStream::new(
|
||||
Box::new(BufferedReader { input: buf_reader }),
|
||||
ctrlc,
|
||||
false,
|
||||
call_span,
|
||||
),
|
||||
call_span,
|
||||
|
@ -362,7 +362,6 @@ fn response_to_buffer(
|
||||
input: buffered_input,
|
||||
}),
|
||||
engine_state.ctrlc.clone(),
|
||||
false,
|
||||
span,
|
||||
),
|
||||
span,
|
||||
|
@ -243,7 +243,7 @@ impl ExternalCommand {
|
||||
let receiver = ChannelReceiver::new(rx);
|
||||
|
||||
Ok(PipelineData::RawStream(
|
||||
RawStream::new(Box::new(receiver), output_ctrlc, true, head),
|
||||
RawStream::new(Box::new(receiver), output_ctrlc, head),
|
||||
head,
|
||||
None,
|
||||
))
|
||||
|
@ -72,7 +72,6 @@ impl Command for Table {
|
||||
.into_iter(),
|
||||
),
|
||||
ctrlc,
|
||||
false,
|
||||
head,
|
||||
),
|
||||
head,
|
||||
@ -189,7 +188,6 @@ impl Command for Table {
|
||||
stream,
|
||||
}),
|
||||
ctrlc,
|
||||
false,
|
||||
head,
|
||||
),
|
||||
head,
|
||||
|
@ -150,8 +150,6 @@ impl PipelineData {
|
||||
PipelineData::RawStream(s, ..) => {
|
||||
let mut items = vec![];
|
||||
|
||||
let trim_end = s.trim_end;
|
||||
|
||||
for val in s {
|
||||
match val {
|
||||
Ok(val) => {
|
||||
@ -173,10 +171,6 @@ impl PipelineData {
|
||||
}
|
||||
}
|
||||
|
||||
if trim_end {
|
||||
output = output.trim_end().to_string();
|
||||
}
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user