Skip to content

Commit

Permalink
Fix "type" error in multi.rs
Browse files Browse the repository at this point in the history
The `orphan_lines_message_above_progress_bar` tests now pass. But the
`multi_progress_println_terminal_wrap` test fails.
  • Loading branch information
smoelius authored and chris-laplante committed Dec 23, 2023
1 parent 69ba17c commit e68cb3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/draw_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ const MAX_BURST: u8 = 20;
pub(crate) struct DrawState {
/// The lines to print (can contain ANSI codes)
pub(crate) lines: Vec<String>,
/// The number of lines that shouldn't be reaped by the next tick.
/// The number [`Self::lines`] entries that shouldn't be reaped by the next tick.
///
/// Note that this number may be different than the number of visual lines required to draw [`Self::lines`].
pub(crate) orphan_lines_count: usize,
/// True if we should move the cursor up when possible instead of clearing lines.
pub(crate) move_cursor: bool,
Expand Down
8 changes: 4 additions & 4 deletions src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,20 @@ impl MultiState {
self.zombie_lines_count = 0;
}

let orphan_lines_count = visual_line_count(&self.orphan_lines, width);
force_draw |= orphan_lines_count > 0;
let orphan_visual_line_count = visual_line_count(&self.orphan_lines, width);
force_draw |= orphan_visual_line_count > 0;
let mut drawable = match self.draw_target.drawable(force_draw, now) {
Some(drawable) => drawable,
None => return Ok(()),
};

let mut draw_state = drawable.state();
draw_state.orphan_lines_count = orphan_lines_count;
draw_state.orphan_lines_count = self.orphan_lines.len();
draw_state.alignment = self.alignment;

if let Some(extra_lines) = &extra_lines {
draw_state.lines.extend_from_slice(extra_lines.as_slice());
draw_state.orphan_lines_count += visual_line_count(extra_lines, width);
draw_state.orphan_lines_count += extra_lines.len();
}

// Add lines from `ProgressBar::println` call.
Expand Down

0 comments on commit e68cb3a

Please sign in to comment.