From 46c286aa57a9406ddc923777a1fe9ecc6091b17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?= Date: Sat, 1 Nov 2025 22:44:32 +0700 Subject: [PATCH] Give more space to right-side diff view --- CHANGELOG.md | 1 + src/popups/inspect_commit.rs | 44 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97dc8a7235..85b318c708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * increase MSRV from 1.81 to 1.82 [[@cruessler](https://github.com/cruessler)] ### Added +* Give more space to right-side diff view [[@hongquan](https://github.com/hongquan)] ([#2772](https://github.com/gitui-org/gitui/pull/2772)) * Support pre-push hook [[@xlai89](https://github.com/xlai89)] ([#1933](https://github.com/extrawurst/gitui/issues/1933)) * Message tab supports pageUp and pageDown [[@xlai89](https://github.com/xlai89)] ([#2623](https://github.com/extrawurst/gitui/issues/2623)) * Files and status tab support pageUp and pageDown [[@fatpandac](https://github.com/fatpandac)] ([#1951](https://github.com/extrawurst/gitui/issues/1951)) diff --git a/src/popups/inspect_commit.rs b/src/popups/inspect_commit.rs index 4acfe88e90..a52b55f1d7 100644 --- a/src/popups/inspect_commit.rs +++ b/src/popups/inspect_commit.rs @@ -67,29 +67,29 @@ pub struct InspectCommitPopup { impl DrawableComponent for InspectCommitPopup { fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { - if self.is_visible() { - let percentages = if self.diff.focused() { - (0, 100) - } else { - (50, 50) - }; - - let chunks = Layout::default() - .direction(Direction::Horizontal) - .constraints( - [ - Constraint::Percentage(percentages.0), - Constraint::Percentage(percentages.1), - ] - .as_ref(), - ) - .split(rect); - - f.render_widget(Clear, rect); - - self.details.draw(f, chunks[0])?; - self.diff.draw(f, chunks[1])?; + if !self.is_visible() { + return Ok(()); } + let constraints = match rect.width { + ..80 => [ + Constraint::Percentage(50), + Constraint::Percentage(50), + ], + 80..100 => [Constraint::Max(32), Constraint::Fill(1)], + 100..120 => [Constraint::Max(40), Constraint::Fill(1)], + 120..140 => [Constraint::Max(48), Constraint::Fill(1)], + _ => [Constraint::Max(52), Constraint::Fill(1)], + }; + + let chunks = Layout::default() + .direction(Direction::Horizontal) + .constraints(constraints) + .split(rect); + + f.render_widget(Clear, rect); + + self.details.draw(f, chunks[0])?; + self.diff.draw(f, chunks[1])?; Ok(()) }