Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
cli/diff: Print cross-platform line endings
Merged lorenz opened 6 months ago
1 file changed +12 -2 d8ab4077 f232acda
modified crates/radicle-cli/src/git/unified_diff.rs
@@ -586,10 +586,20 @@ impl<'a> Writer<'a> {
    }

    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 {
-
            writeln!(self.stream, "{}", term::Paint::new(s).with_style(style))
+
            write!(
+
                self.stream,
+
                "{}{EOL}",
+
                term::Paint::new(s).with_style(style)
+
            )
        } else {
-
            writeln!(self.stream, "{s}")
+
            write!(self.stream, "{s}{EOL}")
        }
    }