From aa4959f8f5c6fa133be5ad9e7648095db24f7147 Mon Sep 17 00:00:00 2001 From: Nissa Date: Sun, 6 Feb 2022 09:42:49 +0000 Subject: [PATCH] Changed MoveToNextLine(0) and MoveToPreviousLine(0) to move 0 lines (#600) --- src/cursor.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index a8d2e4a..a8a1ef2 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -83,12 +83,18 @@ pub struct MoveToNextLine(pub u16); impl Command for MoveToNextLine { fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result { - write!(f, csi!("{}E"), self.0) + if self.0 != 0 { + write!(f, csi!("{}E"), self.0)?; + } + Ok(()) } #[cfg(windows)] fn execute_winapi(&self) -> Result<()> { - sys::move_to_next_line(self.0) + if self.0 != 0 { + sys::move_to_next_line(self.0)?; + } + Ok(()) } } @@ -103,12 +109,18 @@ pub struct MoveToPreviousLine(pub u16); impl Command for MoveToPreviousLine { fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result { - write!(f, csi!("{}F"), self.0) + if self.0 != 0 { + write!(f, csi!("{}F"), self.0)?; + } + Ok(()) } #[cfg(windows)] fn execute_winapi(&self) -> Result<()> { - sys::move_to_previous_line(self.0) + if self.0 != 0 { + sys::move_to_previous_line(self.0)?; + } + Ok(()) } }