cli/diff: Print cross-platform line endings
This commit is contained in:
parent
d8ab40777d
commit
f232acda74
|
|
@ -586,10 +586,20 @@ impl<'a> Writer<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&mut self, s: impl fmt::Display, style: term::Style) -> io::Result<()> {
|
pub fn write(&mut self, s: impl fmt::Display, style: term::Style) -> io::Result<()> {
|
||||||
|
#[cfg(windows)]
|
||||||
|
const EOL: &str = "\r\n";
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
const EOL: &str = "\n";
|
||||||
|
|
||||||
if self.styled {
|
if self.styled {
|
||||||
writeln!(self.stream, "{}", term::Paint::new(s).with_style(style))
|
write!(
|
||||||
|
self.stream,
|
||||||
|
"{}{EOL}",
|
||||||
|
term::Paint::new(s).with_style(style)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
writeln!(self.stream, "{s}")
|
write!(self.stream, "{s}{EOL}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue