From 7dc72380ceac82203181c1442058000de32de58f Mon Sep 17 00:00:00 2001 From: Timur Aliberdov Date: Wed, 7 Oct 2020 00:47:20 +0300 Subject: [PATCH] Draw scrollbar for long commit messages --- CHANGELOG.md | 2 ++ src/components/commit_details/details.rs | 13 ++++++++++++- src/ui/scrollbar.rs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3ac806..26ac1e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ![push](assets/push.gif) +- scrollbar in long commit messages ([#308](https://github.com/extrawurst/gitui/issues/308)) + ### Changed - do not highlight selection in diff view when not focused ([#270](https://github.com/extrawurst/gitui/issues/270)) - compact treeview [[@WizardOhio24](https://github.com/WizardOhio24)] ([#192](https://github.com/extrawurst/gitui/issues/192)) diff --git a/src/components/commit_details/details.rs b/src/components/commit_details/details.rs index 0ef5c738..bb78242d 100644 --- a/src/components/commit_details/details.rs +++ b/src/components/commit_details/details.rs @@ -5,7 +5,7 @@ use crate::{ }, keys::SharedKeyConfig, strings::{self, order}, - ui::style::SharedTheme, + ui::{self, style::SharedTheme}, }; use anyhow::Result; use asyncgit::{ @@ -356,6 +356,17 @@ impl DrawableComponent for DetailsComponent { chunks[1], ); + if self.focused { + ui::draw_scrollbar( + f, + chunks[1], + &self.theme, + self.get_number_of_lines(width as usize) + .saturating_sub(height as usize), + self.scroll_top.get(), + ) + } + Ok(()) } } diff --git a/src/ui/scrollbar.rs b/src/ui/scrollbar.rs index ae835c68..673c3cea 100644 --- a/src/ui/scrollbar.rs +++ b/src/ui/scrollbar.rs @@ -41,7 +41,7 @@ impl Widget for Scrollbar { vertical: 1, }); - if area.height <= 4 { + if area.height < 4 { return; }