Skip to content

Commit ae9cce7

Browse files
author
Paulo Remoli
committed
fix clippy issues
1 parent c650d05 commit ae9cce7

4 files changed

Lines changed: 44 additions & 25 deletions

File tree

src/ui/tab_state/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,10 @@ impl TabState {
15471547
// Extend the continuation map for the newly-appended lines.
15481548
if let (Some(cmap), Some(parser)) = (
15491549
self.continuation_map.as_mut(),
1550-
self.display.format.as_deref().filter(|_| !self.display.raw_mode),
1550+
self.display
1551+
.format
1552+
.as_deref()
1553+
.filter(|_| !self.display.raw_mode),
15511554
) {
15521555
let map = Arc::make_mut(cmap);
15531556
let mut last_parent = map.last().copied().unwrap_or(0);

src/ui/widgets/log_panel.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,12 @@ pub fn prepare_log_panel(
625625
}
626626
// Parent not cached (outside viewport) — parse just
627627
// the level from its raw bytes without full layout.
628-
if let Some(parser) = tab.display.format.as_deref() {
629-
if let Some(parts) = parser.parse_line(tab.file_reader.get_line(parent)) {
630-
if let Some(lvl) = parts.level {
631-
return LogLevel::parse_level(lvl);
632-
}
633-
}
628+
if let Some(parser) = tab.display.format.as_deref()
629+
&& let Some(parts) =
630+
parser.parse_line(tab.file_reader.get_line(parent))
631+
&& let Some(lvl) = parts.level
632+
{
633+
return LogLevel::parse_level(lvl);
634634
}
635635
}
636636
}

src/ui/widgets/source_select_popup.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'a> Widget for DockerSelectPopup<'a> {
3333
if name_w == 0 || c.name.is_empty() {
3434
1u16
3535
} else {
36-
((c.name.chars().count() + name_w - 1) / name_w) as u16
36+
c.name.chars().count().div_ceil(name_w) as u16
3737
}
3838
})
3939
.sum::<u16>()
@@ -100,7 +100,7 @@ impl<'a> Widget for DockerSelectPopup<'a> {
100100
if name_w == 0 || c.name.is_empty() {
101101
1
102102
} else {
103-
(c.name.chars().count() + name_w - 1) / name_w
103+
c.name.chars().count().div_ceil(name_w)
104104
}
105105
})
106106
.collect();
@@ -161,11 +161,7 @@ impl<'a> Widget for DockerSelectPopup<'a> {
161161
let image: String = c.image.chars().take(image_w).collect();
162162
let status: String = c.status.chars().take(status_w).collect();
163163

164-
let first_visible_chunk = if container_start < scroll {
165-
scroll - container_start
166-
} else {
167-
0
168-
};
164+
let first_visible_chunk = scroll.saturating_sub(container_start);
169165

170166
for (chunk_idx, name_chunk) in
171167
name_chunks.iter().enumerate().skip(first_visible_chunk)
@@ -204,9 +200,8 @@ impl<'a> Widget for DockerSelectPopup<'a> {
204200
.render(vsplit[0], buf);
205201

206202
if total_visual_rows > content_h {
207-
let mut sb_state =
208-
ScrollbarState::new(total_visual_rows.saturating_sub(content_h))
209-
.position(scroll);
203+
let mut sb_state = ScrollbarState::new(total_visual_rows.saturating_sub(content_h))
204+
.position(scroll);
210205
StatefulWidget::render(
211206
Scrollbar::new(ScrollbarOrientation::VerticalRight)
212207
.style(Style::default().fg(self.theme.border)),

tests/integration.rs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,9 @@ fn test_build_continuation_map_basic() {
641641
use logana::ui::build_continuation_map;
642642

643643
let reader = make_multiline_log();
644-
let sample: Vec<&[u8]> = (0..reader.line_count()).map(|i| reader.get_line(i)).collect();
644+
let sample: Vec<&[u8]> = (0..reader.line_count())
645+
.map(|i| reader.get_line(i))
646+
.collect();
645647
let parser = detect_format(&sample).expect("format should be detected");
646648

647649
let cmap = build_continuation_map(&reader, parser.as_ref());
@@ -699,7 +701,9 @@ async fn test_exclude_filter_hides_continuation_lines() {
699701

700702
let (_db, mut manager) = setup().await;
701703
let reader = make_multiline_log();
702-
let sample: Vec<&[u8]> = (0..reader.line_count()).map(|i| reader.get_line(i)).collect();
704+
let sample: Vec<&[u8]> = (0..reader.line_count())
705+
.map(|i| reader.get_line(i))
706+
.collect();
703707
let parser = detect_format(&sample).expect("format detected");
704708
let cmap = build_continuation_map(&reader, parser.as_ref());
705709

@@ -714,8 +718,14 @@ async fn test_exclude_filter_hides_continuation_lines() {
714718
// Line 0 (ERROR) excluded; lines 1 & 2 are its continuations → also excluded.
715719
// Line 3 (INFO) should be visible.
716720
assert!(!visible.contains(0), "ERROR entry should be hidden");
717-
assert!(!visible.contains(1), "continuation 1 should be hidden with parent");
718-
assert!(!visible.contains(2), "continuation 2 should be hidden with parent");
721+
assert!(
722+
!visible.contains(1),
723+
"continuation 1 should be hidden with parent"
724+
);
725+
assert!(
726+
!visible.contains(2),
727+
"continuation 2 should be hidden with parent"
728+
);
719729
assert!(visible.contains(3), "INFO entry should be visible");
720730
}
721731

@@ -727,7 +737,9 @@ async fn test_include_filter_shows_continuations_with_parent() {
727737

728738
let (_db, mut manager) = setup().await;
729739
let reader = make_multiline_log();
730-
let sample: Vec<&[u8]> = (0..reader.line_count()).map(|i| reader.get_line(i)).collect();
740+
let sample: Vec<&[u8]> = (0..reader.line_count())
741+
.map(|i| reader.get_line(i))
742+
.collect();
731743
let parser = detect_format(&sample).expect("format detected");
732744
let cmap = build_continuation_map(&reader, parser.as_ref());
733745

@@ -742,7 +754,16 @@ async fn test_include_filter_shows_continuations_with_parent() {
742754
// Line 0 matches; its continuations (1, 2) should be shown.
743755
// Line 3 (INFO) does not match include → hidden.
744756
assert!(visible.contains(0), "ERROR entry should be visible");
745-
assert!(visible.contains(1), "continuation 1 should follow its visible parent");
746-
assert!(visible.contains(2), "continuation 2 should follow its visible parent");
747-
assert!(!visible.contains(3), "INFO entry should be hidden (no match)");
757+
assert!(
758+
visible.contains(1),
759+
"continuation 1 should follow its visible parent"
760+
);
761+
assert!(
762+
visible.contains(2),
763+
"continuation 2 should follow its visible parent"
764+
);
765+
assert!(
766+
!visible.contains(3),
767+
"INFO entry should be hidden (no match)"
768+
);
748769
}

0 commit comments

Comments
 (0)