summaryrefslogtreecommitdiffstats
path: root/ui/src/components/mail/view
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-04-26 12:48:08 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:45 +0300
commitb104a715442bbaad650b40d55095fbbe6dee56fd (patch)
tree0bd3818a41eb3c6c316f79ddc63851bf6f5726ed /ui/src/components/mail/view
parent28859542e8df4666504008fb899bbc4426b4f361 (diff)
ui: highlight entries in ThreadView within grid boundaries
If entry string length + indentation was more than available width an out of index panic occurs when opening the thread.
Diffstat (limited to 'ui/src/components/mail/view')
-rw-r--r--ui/src/components/mail/view/thread.rs34
1 files changed, 23 insertions, 11 deletions
diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs
index 2b591dfc..684d3e33 100644
--- a/ui/src/components/mail/view/thread.rs
+++ b/ui/src/components/mail/view/thread.rs
@@ -301,7 +301,7 @@ impl ThreadView {
false,
);
if let Some(len) = highlight_reply_subjects[y] {
- let index = e.index.0 * 4 + 1 + e.heading.grapheme_width() - len;
+ let index = e.index.0 * 4 + 1;
let area = ((index, 2 * y), (width - 2, 2 * y));
let fg_color = Color::Byte(33);
let bg_color = Color::Default;
@@ -437,11 +437,17 @@ impl ThreadView {
(visual_indentation, 2 * (self.cursor_pos - top_idx)),
),
(
- get_x(upper_left)
- + visual_indentation
- + self.entries[idx].heading.grapheme_width()
- + 1,
- get_y(upper_left) + 2 * (self.cursor_pos - top_idx),
+ cmp::min(
+ get_x(bottom_right),
+ get_x(upper_left)
+ + visual_indentation
+ + self.entries[idx].heading.grapheme_width()
+ + 1,
+ ),
+ cmp::min(
+ get_y(bottom_right),
+ get_y(upper_left) + 2 * (self.cursor_pos - top_idx),
+ ),
),
);
@@ -468,11 +474,17 @@ impl ThreadView {
(visual_indentation, 2 * (visibles[..idx].len() - top_idx)),
),
(
- get_x(upper_left)
- + visual_indentation
- + self.entries[entry_idx].heading.grapheme_width()
- + 1,
- get_y(upper_left) + 2 * (visibles[..idx].len() - top_idx),
+ cmp::min(
+ get_x(bottom_right),
+ get_x(upper_left)
+ + visual_indentation
+ + self.entries[entry_idx].heading.grapheme_width()
+ + 1,
+ ),
+ cmp::min(
+ get_y(bottom_right),
+ get_y(upper_left) + 2 * (visibles[..idx].len() - top_idx),
+ ),
),
);