Skip to content

Commit c486db1

Browse files
committed
feat: help popup display viewing progress
1 parent 90a2269 commit c486db1

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Added
1818
* add popups for viewing, adding, updating and removing remotes [[@robin-thoene](https://github.com/robin-thoene)] ([#2172](https://github.com/extrawurst/gitui/issues/2172))
19+
* help popup display viewing progress[[@wugeer](https://github.com/wugeer)]
1920

2021
## [0.26.3] - 2024-06-02
2122

asyncgit/src/sync/commit_filter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ pub fn filter_commit_by_search(
214214

215215
Ok(msg_summary_match
216216
|| msg_body_match
217-
|| file_match
218-
|| authors_match)
217+
|| file_match || authors_match)
219218
},
220219
))
221220
}

src/popups/help.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ impl DrawableComponent for HelpPopup {
7070
f.render_widget(
7171
Paragraph::new(Line::from(vec![Span::styled(
7272
Cow::from(format!(
73-
"gitui {}",
73+
"gitui {} {}%",
7474
env!("GITUI_BUILD_NAME"),
75+
rounded_div(
76+
((self.selection + 1) as usize) * 100,
77+
self.cmds.len()
78+
)
7579
)),
7680
Style::default(),
7781
)]))
@@ -84,6 +88,14 @@ impl DrawableComponent for HelpPopup {
8488
}
8589
}
8690

91+
const fn rounded_div(numerator: usize, denominator: usize) -> usize {
92+
if numerator % denominator >= (denominator / 2) {
93+
numerator / denominator + 1
94+
} else {
95+
numerator / denominator
96+
}
97+
}
98+
8799
impl Component for HelpPopup {
88100
fn commands(
89101
&self,

src/popups/remotelist.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ impl RemoteListPopup {
245245
.enumerate()
246246
.map(|(i, remote)| {
247247
let selected = (self.selection as usize
248-
- self.scroll.get_top())
249-
== i;
248+
- self.scroll.get_top()) == i;
250249
let mut remote_name = remote.clone();
251250
if remote_name.len()
252251
> name_length

src/tabs/status.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,7 @@ impl Status {
686686
strings::commands::select_staging(&self.key_config),
687687
!focus_on_diff,
688688
(self.visible
689-
&& !focus_on_diff
690-
&& self.focus == Focus::WorkDir)
689+
&& !focus_on_diff && self.focus == Focus::WorkDir)
691690
|| force_all,
692691
)
693692
.order(strings::order::NAV),
@@ -697,8 +696,7 @@ impl Status {
697696
strings::commands::select_unstaged(&self.key_config),
698697
!focus_on_diff,
699698
(self.visible
700-
&& !focus_on_diff
701-
&& self.focus == Focus::Stage)
699+
&& !focus_on_diff && self.focus == Focus::Stage)
702700
|| force_all,
703701
)
704702
.order(strings::order::NAV),

0 commit comments

Comments
 (0)