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/push.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/push.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index a0bcea3..05c9197 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -39,9 +39,10 @@ use crate::{ | |||
| 39 | git::Repo, | 39 | git::Repo, |
| 40 | list::list_from_remotes, | 40 | list::list_from_remotes, |
| 41 | utils::{ | 41 | utils::{ |
| 42 | find_proposal_and_patches_by_branch_name, get_all_proposals, get_remote_name_by_url, | 42 | count_lines_per_msg_vec, find_proposal_and_patches_by_branch_name, get_all_proposals, |
| 43 | get_short_git_server_name, get_write_protocols_to_try, join_with_and, | 43 | get_remote_name_by_url, get_short_git_server_name, get_write_protocols_to_try, |
| 44 | push_error_is_not_authentication_failure, read_line, set_protocol_preference, Direction, | 44 | join_with_and, push_error_is_not_authentication_failure, read_line, |
| 45 | set_protocol_preference, Direction, | ||
| 45 | }, | 46 | }, |
| 46 | }; | 47 | }; |
| 47 | 48 | ||
| @@ -580,10 +581,11 @@ impl<'a> PushReporter<'a> { | |||
| 580 | } | 581 | } |
| 581 | 582 | ||
| 582 | fn count_all_existing_lines(&self) -> usize { | 583 | fn count_all_existing_lines(&self) -> usize { |
| 583 | self.remote_msgs.len() | 584 | let width = self.term.size().1; |
| 584 | + self.negotiation.len() | 585 | count_lines_per_msg_vec(width, &self.remote_msgs, "remote: ".len()) |
| 585 | + self.transfer_progress_msgs.len() | 586 | + count_lines_per_msg_vec(width, &self.negotiation, 0) |
| 586 | + self.update_reference_errors.len() | 587 | + count_lines_per_msg_vec(width, &self.transfer_progress_msgs, 0) |
| 588 | + count_lines_per_msg_vec(width, &self.update_reference_errors, 0) | ||
| 587 | } | 589 | } |
| 588 | fn process_remote_msg(&mut self, data: &[u8]) { | 590 | fn process_remote_msg(&mut self, data: &[u8]) { |
| 589 | if let Ok(data) = str::from_utf8(data) { | 591 | if let Ok(data) = str::from_utf8(data) { |