From c0bbadcaaf42698d102fa03f6f9267021f3efec0 Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Thu, 23 Dec 2021 11:56:52 +0530 Subject: Manually draw all block cursors --- helix-view/src/editor.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'helix-view/src') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index fff4792d..d65c1fb2 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -116,6 +116,12 @@ pub struct Config { #[derive(Debug, Clone, PartialEq)] pub struct CursorShapeConfig([CursorKind; 3]); +impl CursorShapeConfig { + pub fn from_mode(&self, mode: Mode) -> CursorKind { + self.get(mode as usize).copied().unwrap_or_default() + } +} + impl<'de> Deserialize<'de> for CursorShapeConfig { fn deserialize(deserializer: D) -> Result where @@ -647,12 +653,7 @@ impl Editor { let inner = view.inner_area(); pos.col += inner.x as usize; pos.row += inner.y as usize; - let cursorkind = self - .config - .cursor_shape - .get(doc.mode() as usize) - .copied() - .unwrap_or_default(); + let cursorkind = self.config.cursor_shape.from_mode(doc.mode()); (Some(pos), cursorkind) } else { (None, CursorKind::default()) -- cgit v1.2.3-70-g09d2