mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-08-25 21:06:30 +00:00
bug: fix draw bug where the pipe chars could draw over the end (#2146)
Technically the end could draw over since I did `start..pipe_end`, where `pipe_end` could be equal to `end`. This just caps it at `end - 1`.
This commit is contained in:
@@ -196,8 +196,10 @@ impl Widget for PipeGauge<'_> {
|
||||
gauge_area.width,
|
||||
);
|
||||
|
||||
let pipe_end =
|
||||
start + (f64::from(end.saturating_sub(start)) * self.ratio).floor() as u16;
|
||||
let pipe_end = end.saturating_sub(1).min(
|
||||
start + (f64::from(end.saturating_sub(start)) * self.ratio).floor() as u16,
|
||||
);
|
||||
|
||||
for col in start..pipe_end {
|
||||
if let Some(cell) = buf.cell_mut((col, row)) {
|
||||
cell.set_symbol("|").set_style(Style {
|
||||
|
||||
Reference in New Issue
Block a user