diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-18 11:11:41 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-18 11:11:41 +0100 |
| commit | c7838f952f9e32bb871ea6453595b8b14e8fdd3e (patch) | |
| tree | c3fcb523ba9d64911bcf5abf9728a4e99b67eb32 /src/bin/git_remote_nostr/fetch.rs | |
| parent | 7718a56ab05038e743401ea01628d85edc50ed34 (diff) | |
fix(remote): reporter lines on narrow terminals
remove the correct number of lines when reporter prints to
narrow terminals
Diffstat (limited to 'src/bin/git_remote_nostr/fetch.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/fetch.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index fed9925..5dd6ce8 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs | |||
| @@ -20,9 +20,9 @@ use ngit::{ | |||
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | use crate::utils::{ | 22 | use crate::utils::{ |
| 23 | fetch_or_list_error_is_not_authentication_failure, find_proposal_and_patches_by_branch_name, | 23 | count_lines_per_msg_vec, fetch_or_list_error_is_not_authentication_failure, |
| 24 | get_oids_from_fetch_batch, get_open_proposals, get_read_protocols_to_try, join_with_and, | 24 | find_proposal_and_patches_by_branch_name, get_oids_from_fetch_batch, get_open_proposals, |
| 25 | set_protocol_preference, Direction, | 25 | get_read_protocols_to_try, join_with_and, set_protocol_preference, Direction, |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | pub async fn run_fetch( | 28 | pub async fn run_fetch( |
| @@ -270,7 +270,9 @@ impl<'a> FetchReporter<'a> { | |||
| 270 | } | 270 | } |
| 271 | } | 271 | } |
| 272 | fn count_all_existing_lines(&self) -> usize { | 272 | fn count_all_existing_lines(&self) -> usize { |
| 273 | self.remote_msgs.len() + self.transfer_progress_msgs.len() | 273 | let width = self.term.size().1; |
| 274 | count_lines_per_msg_vec(width, &self.remote_msgs, "remote: ".len()) | ||
| 275 | + count_lines_per_msg_vec(width, &self.transfer_progress_msgs, 0) | ||
| 274 | } | 276 | } |
| 275 | fn just_write_transfer_progress(&self, lines_to_clear: usize) { | 277 | fn just_write_transfer_progress(&self, lines_to_clear: usize) { |
| 276 | let _ = self.term.clear_last_lines(lines_to_clear); | 278 | let _ = self.term.clear_last_lines(lines_to_clear); |
| @@ -279,7 +281,8 @@ impl<'a> FetchReporter<'a> { | |||
| 279 | } | 281 | } |
| 280 | } | 282 | } |
| 281 | fn just_count_transfer_progress(&self) -> usize { | 283 | fn just_count_transfer_progress(&self) -> usize { |
| 282 | self.transfer_progress_msgs.len() | 284 | let width = self.term.size().1; |
| 285 | count_lines_per_msg_vec(width, &self.transfer_progress_msgs, 0) | ||
| 283 | } | 286 | } |
| 284 | fn process_remote_msg(&mut self, data: &[u8]) { | 287 | fn process_remote_msg(&mut self, data: &[u8]) { |
| 285 | if let Ok(data) = str::from_utf8(data) { | 288 | if let Ok(data) = str::from_utf8(data) { |