diff options
author | Blaž Hrastnik | 2021-06-27 14:21:25 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-27 14:28:22 +0000 |
commit | 82fc28a0ce2cb2b86968335f32e95aaff3e2cba4 (patch) | |
tree | 6522163ca4b83e93cd1b467ef8f07d883dfdc2b4 /helix-term/src/ui | |
parent | bcca152ad54a5b7ae1615f8cd18c63eeb96b866d (diff) |
ui: Simplify conditional
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r-- | helix-term/src/ui/editor.rs | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f59c158d..d86b0793 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -361,27 +361,26 @@ impl EditorView { if let Some(syntax) = doc.syntax() { use helix_core::match_brackets; let pos = doc.selection(view.id).cursor(); - let pos = match_brackets::find(syntax, doc.text(), pos); + let pos = match_brackets::find(syntax, doc.text(), pos) + .and_then(|pos| view.screen_coords_at_pos(doc, text, pos)); + if let Some(pos) = pos { - let pos = view.screen_coords_at_pos(doc, text, pos); - if let Some(pos) = pos { - if (pos.col as u16) < viewport.width + view.first_col as u16 - && pos.col >= view.first_col - { - let style = - theme.try_get("ui.cursor.match").unwrap_or_else(|| { - Style::default() - .add_modifier(Modifier::REVERSED) - .add_modifier(Modifier::DIM) - }); - - surface - .get_mut( - viewport.x + pos.col as u16, - viewport.y + pos.row as u16, - ) - .set_style(style); - } + // ensure col is on screen + if (pos.col as u16) < viewport.width + view.first_col as u16 + && pos.col >= view.first_col + { + let style = theme.try_get("ui.cursor.match").unwrap_or_else(|| { + Style::default() + .add_modifier(Modifier::REVERSED) + .add_modifier(Modifier::DIM) + }); + + surface + .get_mut( + viewport.x + pos.col as u16, + viewport.y + pos.row as u16, + ) + .set_style(style); } } } |