aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorIvan Tham2021-06-03 17:46:32 +0000
committerBlaž Hrastnik2021-06-04 00:25:03 +0000
commit29b9eed33c07c99fb9345a6832d3431157981e52 (patch)
tree51a4dece657ae77a4057d4f1065645a37bea87be /helix-term/src/ui
parentfdb5bfafaec05f64f2e759717aade5131496557b (diff)
Fix panic paint mysterious matching pair
When the matching pair is out of bounds it still paints it causing an out of bound panic. A dirty fix since it still have some issue, at least it does not panic now.
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index b1c4ce3f..e5d9f679 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -306,6 +306,7 @@ impl EditorView {
),
cursor_style,
);
+ // TODO: set cursor position for IME
if let Some(syntax) = doc.syntax() {
use helix_core::match_brackets;
let pos = doc.selection(view.id).cursor();
@@ -313,10 +314,15 @@ impl EditorView {
if let Some(pos) = pos {
let pos = view.screen_coords_at_pos(doc, text, pos);
if let Some(pos) = pos {
- let style = Style::default().add_modifier(Modifier::REVERSED);
- surface
- .get_mut(pos.col as u16 + OFFSET, pos.row as u16)
- .set_style(style);
+ // this only prevents panic due to painting selection too far
+ // TODO: prevent painting when scroll past x or in gutter
+ // TODO: use a more correct width check
+ if (pos.col as u16) < viewport.width {
+ let style = Style::default().add_modifier(Modifier::REVERSED);
+ surface
+ .get_mut(pos.col as u16 + OFFSET, pos.row as u16)
+ .set_style(style);
+ }
}
}
}