From 2e3127c692d4cd8729848d71043415c8e3442248 Mon Sep 17 00:00:00 2001 From: Peter Hebden Date: Wed, 30 Aug 2023 22:37:04 +0100 Subject: [PATCH] fix: correct behaviour of `ClearType::All` (#63) fix #63 --- CHANGELOG.md | 1 + src/branch.rs | 3 ++- src/render/terminal.rs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc74bd0..17172a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased](https://github.com/Piturnah/gex/compare/v0.6.2...main) ### Fixed - Entering unreachable code on inserting trailing newline ([#62](https://github.com/Piturnah/gex/issues/62)) +- Incorrect positioning of "new branch" prompt ([#63](https://github.com/Piturnah/gex/issues/63)) ## [0.6.2](https://github.com/Piturnah/gex/compare/v0.6.1...v0.6.2) - 2023-08-10 ### Added diff --git a/src/branch.rs b/src/branch.rs index 3d29cd7..c3be24a 100644 --- a/src/branch.rs +++ b/src/branch.rs @@ -86,7 +86,8 @@ impl BranchList { pub fn checkout_new() -> Result { terminal::disable_raw_mode().context("failed to exit raw mode")?; print!( - "{}{}Name for the new branch: ", + "{}{}{}Name for the new branch: ", + cursor::MoveTo(0, 0), Clear(ClearType::All), cursor::Show ); diff --git a/src/render/terminal.rs b/src/render/terminal.rs index 949de29..e7542f9 100644 --- a/src/render/terminal.rs +++ b/src/render/terminal.rs @@ -28,11 +28,11 @@ impl fmt::Display for Clear { write!(f, "{}", style::SetBackgroundColor(color))?; match self.0 { ClearType::All => { - write!(f, "{}", cursor::MoveTo(0, 0),)?; + write!(f, "{}{}", cursor::SavePosition, cursor::MoveTo(0, 0),)?; for _ in 0..rows { write!(f, "{:width$}", ' ', width = cols as usize)?; } - write!(f, "{}", cursor::MoveTo(0, 0)) + write!(f, "{}", cursor::RestorePosition) } ClearType::Purge => write!( f,