Browse Source

utilities/StatusBar: fix lack of bounds checking in hist_area

jmap-eventsource
Manos Pitsidianakis 1 year ago
parent
commit
79345b3e84
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 45
      src/components/utilities.rs

45
src/components/utilities.rs

@ -304,15 +304,19 @@ impl Component for StatusBar {
}
let hist_height = std::cmp::min(15, self.auto_complete.suggestions().len());
let hist_area = if height < self.auto_complete.suggestions().len() {
ScrollBar::default().set_show_arrows(false).draw(
grid,
let hist_area = (
(
(
get_x(upper_left),
get_x(upper_left),
std::cmp::min(
get_y(bottom_right) - height - hist_height + 1,
get_y(bottom_right),
),
set_y(bottom_right, get_y(bottom_right) - height),
),
pos_dec(bottom_right, (0, height)),
);
ScrollBar::default().set_show_arrows(false).draw(
grid,
hist_area,
context,
self.auto_complete.cursor(),
hist_height,
@ -320,37 +324,22 @@ impl Component for StatusBar {
);
change_colors(
grid,
(
(
get_x(upper_left),
get_y(bottom_right) - height - hist_height + 1,
),
set_y(bottom_right, get_y(bottom_right) - height),
),
hist_area,
Color::Byte(197), // DeepPink2,
Color::Byte(174), //LightPink3
);
context.dirty_areas.push_back((
(
get_x(upper_left),
get_y(bottom_right) - height - hist_height + 1,
),
set_y(bottom_right, get_y(bottom_right) - height),
));
(
(
get_x(upper_left) + 1,
get_y(bottom_right) - height - hist_height + 1,
),
set_y(bottom_right, get_y(bottom_right) - height),
)
context.dirty_areas.push_back(hist_area);
hist_area
} else {
(
(
get_x(upper_left),
get_y(bottom_right) - height - hist_height + 1,
std::cmp::min(
get_y(bottom_right) - height - hist_height + 1,
get_y(bottom_right),
),
),
set_y(bottom_right, get_y(bottom_right) - height),
pos_dec(bottom_right, (0, height)),
)
};
let offset = if hist_height

Loading…
Cancel
Save