From 0d42c851959214015e736396b9bf491d0725cae6 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Thu, 10 Mar 2022 01:09:25 -0800 Subject: [PATCH] fix formatting --- crates/editor/src/editor.rs | 5 +---- crates/editor/src/element.rs | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 711fee890be3ce520df8b6b536c17d263c044430..32a81f4f692f0d48a93734c2dfc4caf59301fe0d 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1023,10 +1023,7 @@ impl Editor { cx.notify(); } - pub fn set_cursor_shape( - &mut self, - cursor_shape: CursorShape - ) { + pub fn set_cursor_shape(&mut self, cursor_shape: CursorShape) { self.cursor_shape = cursor_shape; // TODO: Do we need to notify? } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 85e34108d7a01f29cc08231fad6aec72ac0a9a4d..822d3ab0855b5622e4ce39b996d1c51565ad196f 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -36,8 +36,16 @@ pub struct EditorElement { } impl EditorElement { - pub fn new(view: WeakViewHandle, style: EditorStyle, cursor_shape: CursorShape) -> Self { - Self { view, style, cursor_shape } + pub fn new( + view: WeakViewHandle, + style: EditorStyle, + cursor_shape: CursorShape, + ) -> Self { + Self { + view, + style, + cursor_shape, + } } fn view<'a>(&self, cx: &'a AppContext) -> &'a Editor { @@ -365,7 +373,8 @@ impl EditorElement { &layout.line_layouts[(cursor_position.row() - start_row) as usize]; let cursor_column = cursor_position.column() as usize; let cursor_character_x = cursor_row_layout.x_for_index(cursor_column); - let mut character_width = cursor_row_layout.x_for_index(cursor_column + 1) - cursor_character_x; + let mut character_width = + cursor_row_layout.x_for_index(cursor_column + 1) - cursor_character_x; // TODO: Is there a better option here for the character size // at the end of the line? // Default to 1/3 the line height @@ -1228,7 +1237,7 @@ impl PaintState { pub enum CursorShape { Bar, Block, - Underscore + Underscore, } impl Default for CursorShape { @@ -1242,17 +1251,20 @@ struct Cursor { character_width: f32, line_height: f32, color: Color, - shape: CursorShape + shape: CursorShape, } impl Cursor { fn paint(&self, cx: &mut PaintContext) { let bounds = match self.shape { CursorShape::Bar => RectF::new(self.origin, vec2f(2.0, self.line_height)), - CursorShape::Block => RectF::new(self.origin, vec2f(self.character_width, self.line_height)), + CursorShape::Block => { + RectF::new(self.origin, vec2f(self.character_width, self.line_height)) + } CursorShape::Underscore => RectF::new( self.origin + Vector2F::new(0.0, self.line_height - 2.0), - vec2f(self.character_width, 2.0)), + vec2f(self.character_width, 2.0), + ), }; cx.scene.push_quad(Quad {