mirror of
https://github.com/nushell/nushell
synced 2025-01-16 07:04:09 +00:00
Decode escaped newlines in history command (#592)
Reedline currently encodes newlines as `<\n>`
This commit is contained in:
parent
e62e0fb679
commit
39f03bf5e4
1 changed files with 7 additions and 1 deletions
|
@ -4,6 +4,12 @@ use nu_protocol::{
|
||||||
Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value,
|
Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const NEWLINE_ESCAPE_CODE: &str = "<\\n>";
|
||||||
|
|
||||||
|
fn decode_newlines(escaped: &str) -> String {
|
||||||
|
escaped.replace(NEWLINE_ESCAPE_CODE, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct History;
|
pub struct History;
|
||||||
|
|
||||||
|
@ -48,7 +54,7 @@ impl Command for History {
|
||||||
Ok(contents
|
Ok(contents
|
||||||
.lines()
|
.lines()
|
||||||
.map(move |x| Value::String {
|
.map(move |x| Value::String {
|
||||||
val: x.to_string(),
|
val: decode_newlines(x),
|
||||||
span: head,
|
span: head,
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
Loading…
Reference in a new issue