Skip to content

Commit

Permalink
fix scrollbar crash + add offset for input visual scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Chleba committed Apr 20, 2024
1 parent 0e31b84 commit 52e2095
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ impl Discovery {
}

fn set_scrollbar_height(&mut self) {
self.scrollbar_state = self
.scrollbar_state
.content_length(self.scanned_ips.len() - 1);
let mut ip_len = 0;
if self.scanned_ips.len() > 0 {
ip_len = self.scanned_ips.len() - 1;
}
self.scrollbar_state = self.scrollbar_state.content_length(ip_len);
}

fn previous_in_table(&mut self) {
Expand Down Expand Up @@ -560,7 +562,6 @@ impl Component for Discovery {
// -- first time scan after setting of interface
if self.active_interface.is_none() {
self.set_active_subnet(&intf);

}
self.active_interface = Some(intf);
}
Expand Down Expand Up @@ -643,7 +644,8 @@ impl Component for Discovery {
input_size,
3,
);
let scroll = self.input.visual_scroll(INPUT_SIZE);
// -- INPUT_SIZE - 3 is offset for border + 1char for cursor
let scroll = self.input.visual_scroll(INPUT_SIZE - 3);
let mut block = self.make_input(scroll);
if self.is_scanning {
block = block.clone().add_modifier(Modifier::DIM);
Expand Down

0 comments on commit 52e2095

Please sign in to comment.