summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-24 10:38:34 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-24 14:28:28 +0200
commit79345b3e840b83470535731c74abb5d7fd1b0142 (patch)
tree8aa511d7f5fceb3b9ee0c1121f1ba63172e9d8c4 /src
parentb46cd09ca6abee4603d22373bff4c34148bc222f (diff)
utilities/StatusBar: fix lack of bounds checking in hist_area
Diffstat (limited to 'src')
-rw-r--r--src/components/utilities.rs45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/components/utilities.rs b/src/components/utilities.rs
index 4346a634..ac724f40 100644
--- a/src/components/utilities.rs
+++ b/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